Skip to main content

All Questions

1 vote
1 answer
143 views

How to update certain value of xml parameter via script python

Im trying to implement a script python that update a specific value of the xml parameters. my issue that the parameter that I want to update appears multiple times respectively one row after the other....
Dan Zhavi's user avatar
1 vote
1 answer
730 views

Text File Parsing with Python?! unique pattern of txt words

I am trying to parse a series of messages from the text file and save them as txt files using Python (2.7.3) or any other python versions. I have txt file like this .txt : [#11:23][INFO][0x0015a] it's ...
Maher's user avatar
  • 11
1 vote
1 answer
922 views

How can I cause a Memory Error in python 2.7?

I'm working on a system that has about 128KB of RAM, one of my scripts occasionally causes a ERRNO 12 Cannot Allocate Memory error. I have a few solutions I want to test. But how can I replicate the ...
MrRobot's user avatar
  • 21
-1 votes
1 answer
69 views

list index out of range when performing database queries in Hypothesis function

I'm using Python Hypothesis to write random tests for database. After 1-2 loops of insert the given values to the table I get list index out of range and @seed to reproduce. There is nothing that ...
Shani Noyman's user avatar
5 votes
1 answer
724 views

Using a fixture inside pytest.mark.parametrize

Say I have a test function that takes a parametrize record as a dict, where one of its values is a fixture which is already defined. For example, we have a fixture: @pytest.fixture def a_value(): ...
A. Sarid's user avatar
  • 3,996
0 votes
1 answer
299 views

Is there a way to test if flask template contains a link?

I've been testing whether routes exist using def test_index(self): r = self.app.get("/") self.assertEqual(200, r.status_code, "Status code was not 'OK'.") My template has a hyperlink to ...
Bryan's user avatar
  • 1
-1 votes
1 answer
66 views

How to unit test variable reassignment in Python

Main question: What is the most efficient way to unit test whether a class variable (self.file_path) was successfully reassigned by a method given the below class? class FileHandler(object): def ...
Tyler Dane's user avatar
  • 1,031
0 votes
1 answer
279 views

Mocking a static function call with a long chain of calls in python 2.7

I'm trying to test a large legacy Django application, and I'm getting confused by Python mocking as I have never worked on large Python application. Specifically, I have method has a long call chain ...
nflacco's user avatar
  • 5,032
2 votes
2 answers
2k views

Running pytest.main(...) does not collect tests

I've created a sub folder with test_*.py files and additional .py files which hold additional methods which are being called. In the root directory of the project I've created main_test.py in which I ...
Bored002's user avatar
  • 363
4 votes
1 answer
3k views

Parametrize the test based on the list test-data from a json file

Is there a way to parametrize a test, when test has a list of different/multiple test-data? example_test_data.json { "test_one" : [1,2,3], # this is the case, where the `test_one` test need to be ...
Sunil Kumar's user avatar
1 vote
1 answer
112 views

NameError: name 'zombie_array' is not defined

I have a python code (q4.py) given below: #!/usr/bin/env python def DFS(j, visited, zombies, row): for k in range(row): if zombies[j][k] == '1' and visited[j][k] == False and visited[k][...
Rowle's user avatar
  • 13
0 votes
0 answers
282 views

Unable to run an individual test with Django 1.8

Having followed the advice in these two answers, I'm still unable to run only a single django test in the way it describes. I can run them all, but that takes a long time and makes debugging harder. ...
James Bradbury's user avatar
1 vote
1 answer
2k views

How do I mock a python function that's imported using an alias within a test

I'm trying to mock a function that's imported from a library which is renamed. The example mylibrarywithlongname: def helloworld(): return "hello world" def helloworld_helper(): return ...
576i's user avatar
  • 8,112
3 votes
1 answer
2k views

How to mock Python classes when nested several dependencies deep

If I have the following architecture... Please note the edits below. It occurred to me (after some recent refactoring) that there are actually three classes in three different files. Sorry that the ...
John Carrell's user avatar
  • 1,820
1 vote
2 answers
704 views

Same test for different states of the same object without persisting changes

I am trying to run the same exact test on a single obj which is a models.Model instance and has some relations with other models. I do not want to persist changes in that instance, so effectively I ...
dabadaba's user avatar
  • 9,412

15 30 50 per page
1
2 3 4 5