'Custom command line parameter for testing
I found a way to pass a custom parameter to Django testing from command line:
class TestRunner(DiscoverRunner):
def __init__(self, option=None, **kwargs):
super().__init__(**kwargs)
self.browser = kwargs['browser']
@classmethod
def add_arguments(cls, parser):
DiscoverRunner.add_arguments(parser)
parser.add_argument('-br', '--browser', help='Browser test')
def build_suite(self, test_labels=None, extra_tests=None, **kwargs):
suite = unittest.TestSuite()
suite.addTest(TestProjects('test_create_project'))
return suite
But how can I get this parameter value inside my TestCase ?. Maybe a way is to pass self.browser parameter inside TestProjects class ? If yes how can I do that
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
