回答編集履歴
3
オプション間違いの訂正。結果の追記。
answer
CHANGED
@@ -29,10 +29,13 @@
|
|
29
29
|
> プロジェクトの最上位のディスカバリのディレクトリ (デフォルトは開始のディレクトリ)
|
30
30
|
```
|
31
31
|
cd (some)/workspacefolder
|
32
|
-
python -m unittest discover -
|
32
|
+
python -m unittest discover -t project -s tests
|
33
33
|
```
|
34
|
-
でunittestを起動するのではないでしょうか。(試していませんが)
|
34
|
+
~~でunittestを起動するのではないでしょうか。(試していませんが)~~
|
35
35
|
|
36
|
+
追記
|
37
|
+
想定されていないディクレトリ構成なのでしょう。`AssertionError: Path must be within the project`が出て停止するようです。
|
38
|
+
|
36
39
|
----
|
37
40
|
|
38
41
|
`__init__.py`は必須ではなくなりました。
|
2
些細
answer
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
あるいは質問の構造であれば、
|
24
24
|
|
25
|
-
[https://docs.python.org/ja/3/library/unittest.html#test-discovery]
|
25
|
+
[https://docs.python.org/ja/3/library/unittest.html#test-discovery](https://docs.python.org/ja/3/library/unittest.html#test-discovery)
|
26
26
|
|
27
27
|
|
28
28
|
> -t, --top-level-directory directory
|
1
追記
answer
CHANGED
@@ -12,8 +12,29 @@
|
|
12
12
|
```
|
13
13
|
だと思います。
|
14
14
|
|
15
|
+
[https://docs.python.org/ja/3/library/unittest.html#command-line-interface](https://docs.python.org/ja/3/library/unittest.html#command-line-interface)
|
16
|
+
|
17
|
+
> python -m unittest tests/test_something.py
|
18
|
+
>
|
19
|
+
> そのため、テストモジュールを指定するのにシェルのファイル名補完が使えます。指定されたファイルはやはりモジュールとしてインポート可能でなければなりません。パスから '.py' を取り除き、パスセパレータを '.' に置き換えることでモジュール名に変換されます。
|
20
|
+
|
15
21
|
----
|
16
22
|
|
23
|
+
あるいは質問の構造であれば、
|
24
|
+
|
25
|
+
[https://docs.python.org/ja/3/library/unittest.html#test-discovery]
|
26
|
+
|
27
|
+
|
28
|
+
> -t, --top-level-directory directory
|
29
|
+
> プロジェクトの最上位のディスカバリのディレクトリ (デフォルトは開始のディレクトリ)
|
30
|
+
```
|
31
|
+
cd (some)/workspacefolder
|
32
|
+
python -m unittest discover -d project tests
|
33
|
+
```
|
34
|
+
でunittestを起動するのではないでしょうか。(試していませんが)
|
35
|
+
|
36
|
+
----
|
37
|
+
|
17
38
|
`__init__.py`は必須ではなくなりました。
|
18
39
|
[https://docs.python.org/ja/3/reference/import.html#module-path](https://docs.python.org/ja/3/reference/import.html#module-path)
|
19
40
|
|