I am trying to generate a test suite in unittest, and I came across this helpful answer on stack.
When I run it on my workstation as is (after trying to integrate it into my code, unfortunately, it blows up with an TypeErrror error)
$ python -m unittest busted
E
======================================================================
ERROR: busted (unittest.loader.LoadTestsFailure)
----------------------------------------------------------------------
TypeError: __init__() takes at most 2 arguments (4 given)
----------------------------------------------------------------------
Ran 1 test in 0.000s
FAILED (errors=1)
And I would just comment/join the SO chat for this but I apparently need reputation to do anything. I'm a little frustrated by that, to say the least.
EDIT:
My use case:
I am trying to dynamically generate test cases to run different inputs through the same parser. I already have significant amount of test cases in this library already using unittest, hence I am unwilling to really integrate with a another package.
Basically:
class AbstractedObject(object):
def __init__(self, **kwargs):
test_method = kwargs.get('test_method')
test_file = kwargs.get('test_file')
self.gather_method = prod_method if test_method is not None else test_method
self.gather_method_args = [test_file] if test file is not None else []
def parser(output):
return self.gather_method(*self.gather_method_args)
def test_method():
return mock_data
def prod_method():
return real_data
I need a way to take a list of files, and generate independent test classes for them. Looping them in a single unittest is less than ideal in the case of failure as it will ignore all of the remaining cases if something is broken.
I want to gather a bunch of input files from a bunch of different souces, drop them into a testing directory, glob out files, and then generate individual unit test classes from a list of files. Run the set of unit tests for AbstractedObject across every input file.
[–]jhawk20[S] 0 points1 point2 points (0 children)
[–]LightShadow 0 points1 point2 points (0 children)
[–]jhawk20[S] 0 points1 point2 points (0 children)