6b3bc8fc42f32fafaed4d47b094031bd859a1163
python/unittest/TypeError: __init__() takes 1 positional argument but 2 were given.md
... | ... | @@ -0,0 +1,38 @@ |
1 | +### 出力されるエラー |
|
2 | +``` |
|
3 | +Traceback (most recent call last): |
|
4 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main |
|
5 | + return _run_code(code, main_globals, None, |
|
6 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code |
|
7 | + exec(code, run_globals) |
|
8 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/__main__.py", line 18, in <module> |
|
9 | + main(module=None) |
|
10 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/main.py", line 100, in __init__ |
|
11 | + self.parseArgs(argv) |
|
12 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/main.py", line 124, in parseArgs |
|
13 | + self._do_discovery(argv[2:]) |
|
14 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/main.py", line 244, in _do_discovery |
|
15 | + self.createTests(from_discovery=True, Loader=Loader) |
|
16 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/main.py", line 154, in createTests |
|
17 | + self.test = loader.discover(self.start, self.pattern, self.top) |
|
18 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/loader.py", line 349, in discover |
|
19 | + tests = list(self._find_tests(start_dir, pattern)) |
|
20 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/loader.py", line 414, in _find_tests |
|
21 | + yield from self._find_tests(full_path, pattern, namespace) |
|
22 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/loader.py", line 405, in _find_tests |
|
23 | + tests, should_recurse = self._find_test_path( |
|
24 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/loader.py", line 460, in _find_test_path |
|
25 | + return self.loadTestsFromModule(module, pattern=pattern), False |
|
26 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/loader.py", line 124, in loadTestsFromModule |
|
27 | + tests.append(self.loadTestsFromTestCase(obj)) |
|
28 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/loader.py", line 93, in loadTestsFromTestCase |
|
29 | + loaded_suite = self.suiteClass(map(testCaseClass, testCaseNames)) |
|
30 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/suite.py", line 24, in __init__ |
|
31 | + self.addTests(tests) |
|
32 | + File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/suite.py", line 57, in addTests |
|
33 | + for test in tests: |
|
34 | +TypeError: __init__() takes 1 positional argument but 2 were given |
|
35 | +``` |
|
36 | + |
|
37 | +### 解決法 |
|
38 | +[python - __init__ for unittest.TestCase - Stack Overflow](https://stackoverflow.com/questions/17353213/init-for-unittest-testcase) |
|
... | ... | \ No newline at end of file |