Если я нажимаю «Выполнить« Unittest for .. »в PyCharm, он печатает:
»
Launching unittests with arguments python -m unittest /home/sfalk/workspace/git/m-search/python/tests/cluster/pipeline/preprocessing.py in /home/sfalk/workspace/git/m-search/python/tests/cluster/pipeline
и отчеты
Тесты не найдены.
Однако, если я скопирую эту точную строку, которую, как утверждает PyCharm, запускает, а именно
python -m unittest /home/sfalk/workspace/git/m-search/python/tests/cluster/pipeline/preprocessing.py
тогда я получаю ожидаемый результат.
$ python -m unittest /home/sfalk/workspace/git/m-search/python/tests/cluster/pipeline/preprocessing.py
..
+---+------------+
| _1| _2|
+---+------------+
| 1|Hello World!|
+---+------------+
.
----------------------------------------------------------------------
Ran 1 test in 4.998s
OK
Конфигурация запуска говорит:
Путь к сценарию: /home/sfalk/workspace/git/m-search/python/tests/cluster/pipeline/preprocessing.py
Рабочий каталог: /home/sfalk/workspace/git/m-search/python/tests/cluster/pipeline
Я не понимаю ..
Имхо, это неважно, но вот код модульного теста:
import unittest
from pyspark import SparkContext, SparkConf, SQLContext
class TestPreprocessingText(unittest.TestCase):
def test_preprocessingText(self):
conf = SparkConf()
conf.setMaster('local')
conf.setAppName('MyApp')
sc = SparkContext.getOrCreate()
sql = SQLContext(sc)
df = sql.createDataFrame(
[
(1, 'Hello World!')
]
)
df.show()
if __name__ == '__main__':
unittest.main()