Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
183 views

How to unit test a function with a large input data that is essential for the expected output?

I have a dilemma in unit testing. In the following code, the model.bin file is very large and takes 10 minutes to load on my system, which hinders the testing efficiency. However, if I use a smaller ...
Ayub Kokabi's user avatar
0 votes
1 answer
347 views

How to automatically generate unit testing routines from special syntax in method docstring / comment?

This is a mock-up of what I'm looking for: def is_even(a, b): """Returns True if both numbers are even. @AutoUnitTestTag: - (0,2) -> True - (2,1) -> False - (3,...
jwav's user avatar
  • 625
1 vote
1 answer
344 views

Python doctest match expected with hex notation, without custom OutputChecker

I commonly work with bytes and hex, and have a bunch of helper methods for working with these numbers. I am adding doctests into my docstrings, to help make sure they work. See the below example: ...
Intrastellar Explorer's user avatar
1 vote
2 answers
316 views

How to doctest functions with volatile output?

By the time the doctest is run, the volatile output is different thus the test fails. Ideally (but not necessarily), the solution should try to avoid to write testable code outside the docstring in ...
Elrond's user avatar
  • 2,112
0 votes
0 answers
234 views

Python: Unittest testing based on Docstring?

I am new to using unittest for testing my modules. Usually docstrings already contain a lot of useful info such as the datatypes expected by a function or the datatype of the return value. E.g. def ...
Suppenkasper's user avatar
0 votes
1 answer
250 views

Keep lines inside docstrings within 79 character limit

I am writing some doctests in my module. Relevant code def foo(): """ Populates the database with 'VALUES' >>> import sqlite3 >>> con = sqlite3.connect('test.db') ...
Tasdik Rahman's user avatar
1 vote
1 answer
80 views

How can I prevent django test from running examples in docstrings?

In my code I have: def fn1(): """ fn1 description Parameters ---------- components_list : list List of IDs of the reference groups Return ------ ret : str ...
A. B's user avatar
  • 717
2 votes
2 answers
643 views

Put python doctest at the end of the code file?

I can put python doctests in the bodies of each function, which I sometimes like for small libraries, because they are in the same file as the function. Or I can put them all together into a seperate ...
mit's user avatar
  • 11.2k
1 vote
2 answers
1k views

How to change docstring of TestCase Class in Python?

In Python 2.5 (Jython actually), for the UnitTest TestCase Class - there's is no SetUpClass method, and __init__ is not really acceptable (no refference to self). When I try to change docstring inside ...
Noam Manos's user avatar
  • 16.9k
4 votes
1 answer
2k views

how to change the test description of python (2.7) untitest

It seems that the unittest module has been changed a lot in Python 2.7 I have a test case: class DemoTest(unittest.TestCase): def test_foo(self): """Test foo""" pass The console ...
stanleyxu2005's user avatar
29 votes
5 answers
23k views

How should unit tests be documented? [closed]

I'm trying to improve the number and quality of tests in my Python projects. One of the the difficulties I've encountered as the number of tests increase is knowing what each test does and how it's ...
ddbeck's user avatar
  • 3,945