【发布时间】:2018-06-06 05:31:05
【问题描述】:
我编写了一个名为scraping_test.py 的python 测试文件,它有一个测试类,使用unittest,名为TestScrapingUtils
"""Tests for the scraping app"""
import unittest
from bs4 import BeautifulSoup as bs4
from mosque_scraper.management.commands import scraping_utils
from mosque_scraper.selectors import MOSQUE_INFO_ROWS_SELECTOR
class TestScrapingUtils(unittest.TestCase):
"""Test scraping_utils.py """
def setup(self):
"""Setup McSetupface."""
pass
def test_get_keys_from_row(self):
""" Test that we extract the correct keys from the supplied rows."""
test_page_name = "test_page.html"
with open(test_page_name) as test_page_file:
test_mosque = bs4(test_page_file, 'html.parser')
rows = test_mosque.select(MOSQUE_INFO_ROWS_SELECTOR)
field_dict = scraping_utils.get_fields_from_rows(rows)
self.assertDictEqual(field_dict, {})
我的单元测试设置是:
{
"python.unitTest.unittestEnabled": true,
"python.unitTest.unittestArgs": [
"-v",
"-s",
".",
"-p",
"*test.py"
]
}
它看起来应该可以工作,但是当我点击在 VSCode 中运行测试时,它说没有发现任何测试:
未发现测试,请检查测试的配置设置。
如何让它发挥作用?
【问题讨论】:
标签: python visual-studio-code python-unittest