mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-06 11:00:46 +00:00
Drop the remaining unittest.main() blocks. (#6602)
This commit is contained in:
parent
b10d46d280
commit
6ae5b92671
@ -566,7 +566,3 @@ class RFC2616PolicyTest(DefaultStorageTest):
|
||||
res2 = self._process_requestresponse(mw, req0, None)
|
||||
self.assertEqualResponse(res1, res2)
|
||||
assert "cached" in res2.flags
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -1314,7 +1314,3 @@ def test_meta_refresh_schemes(url, location, target):
|
||||
else:
|
||||
assert isinstance(redirect, Request)
|
||||
assert redirect.url == target
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -643,7 +643,3 @@ class GetRetryRequestTest(unittest.TestCase):
|
||||
f"{stats_key}/reason_count/{expected_reason}",
|
||||
):
|
||||
self.assertEqual(spider.crawler.stats.get_value(stat), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -699,7 +699,3 @@ class CustomExporterItemTest(unittest.TestCase):
|
||||
|
||||
class CustomExporterDataclassTest(CustomExporterItemTest):
|
||||
item_class = TestDataClass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -1717,7 +1717,3 @@ class JsonRequestTest(RequestTest):
|
||||
def tearDown(self):
|
||||
warnings.resetwarnings()
|
||||
super().tearDown()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -296,7 +296,3 @@ class ItemMetaClassCellRegression(unittest.TestCase):
|
||||
# TypeError: __class__ set to <class '__main__.MyItem'>
|
||||
# defining 'MyItem' as <class '__main__.MyItem'>
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -586,7 +586,3 @@ class FunctionProcessorTestCase(unittest.TestCase):
|
||||
lo.add_value("foo", " bar ")
|
||||
lo.add_value("foo", [" asdf ", " qwerty "])
|
||||
self.assertEqual(dict(lo.load_item()), {"foo": ["BAR", "ASDF", "QWERTY"]})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -715,7 +715,3 @@ class FunctionProcessorTestCase(unittest.TestCase):
|
||||
lo.add_value("foo", " bar ")
|
||||
lo.add_value("foo", [" asdf ", " qwerty "])
|
||||
self.assertEqual(dict(lo.load_item()), {"foo": ["BAR", "ASDF", "QWERTY"]})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -234,7 +234,3 @@ class ShowOrSkipMessagesTestCase(TwistedTestCase):
|
||||
self.assertNotIn("Scraped from <200 http://127.0.0.1:", str(lc))
|
||||
self.assertNotIn("Crawled (200) <GET http://127.0.0.1:", str(lc))
|
||||
self.assertNotIn("Dropped: Ignoring item", str(lc))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -157,7 +157,3 @@ class MailSenderTest(unittest.TestCase):
|
||||
|
||||
context = factory.buildProtocol("test@scrapy.org").context
|
||||
self.assertIsInstance(context, ClientTLSOptions)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -126,7 +126,3 @@ class ResponseTypesTest(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
responsetypes.mimetypes.guess_type("x.scrapytest")[0], "x-scrapy/test"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -497,7 +497,3 @@ class SettingsTest(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
str(error.exception), "Trying to modify an immutable Settings object"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -177,7 +177,3 @@ class FeedExportConfigTestCase(unittest.TestCase):
|
||||
"item_export_kwargs": {},
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -38,7 +38,3 @@ class UtilsConsoleTestCase(unittest.TestCase):
|
||||
# default shell should be 'ipython'
|
||||
shell = get_shell_embed_func()
|
||||
self.assertEqual(shell.__name__, "_embed_ipython_shell")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -372,7 +372,3 @@ class LocalWeakReferencedCacheTest(unittest.TestCase):
|
||||
for i, r in enumerate(refs):
|
||||
self.assertIn(r, cache)
|
||||
self.assertEqual(cache[r], i)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -20,7 +20,3 @@ class HttpobjUtilsTest(unittest.TestCase):
|
||||
assert req1a is req1b
|
||||
assert req1a is not req2
|
||||
assert req1a is not req2
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -216,7 +216,3 @@ class UtilsMiscTestCase(unittest.TestCase):
|
||||
assert rel_has_nofollow("nofollowfoo") is False
|
||||
assert rel_has_nofollow("foonofollow") is False
|
||||
assert rel_has_nofollow("ugc, , nofollow") is True
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -481,7 +481,3 @@ class RequestToCurlTest(unittest.TestCase):
|
||||
" --data-raw '{\"foo\": \"bar\"}' --cookie 'foo=bar'"
|
||||
)
|
||||
self._test_request(request_object, expected_curl_command)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -295,7 +295,3 @@ Disallow: /forum/active/
|
||||
)
|
||||
|
||||
self.assertEqual(list(s), [{"loc": "http://127.0.0.1:8000/"}])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -30,7 +30,3 @@ class UtilsSpidersTestCase(unittest.TestCase):
|
||||
|
||||
it = iter_spider_classes(tests.test_utils_spider)
|
||||
self.assertEqual(set(it), {MySpider1, MySpider2})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
@ -33,7 +33,3 @@ class UtilsRenderTemplateFileTestCase(unittest.TestCase):
|
||||
|
||||
render_path.unlink()
|
||||
assert not render_path.exists() # Failure of test itself
|
||||
|
||||
|
||||
if "__main__" == __name__:
|
||||
unittest.main()
|
||||
|
@ -630,7 +630,3 @@ def test_deprecated_imports_from_w3lib(obj_name):
|
||||
getattr(import_module("scrapy.utils.url"), obj_name)
|
||||
|
||||
assert message in warns[0].message.args
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user