1
0
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:
Andrey Rakhmatullin 2025-01-02 15:45:04 +04:00 committed by GitHub
parent b10d46d280
commit 6ae5b92671
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
22 changed files with 0 additions and 88 deletions

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -699,7 +699,3 @@ class CustomExporterItemTest(unittest.TestCase):
class CustomExporterDataclassTest(CustomExporterItemTest):
item_class = TestDataClass
if __name__ == "__main__":
unittest.main()

View File

@ -1717,7 +1717,3 @@ class JsonRequestTest(RequestTest):
def tearDown(self):
warnings.resetwarnings()
super().tearDown()
if __name__ == "__main__":
unittest.main()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -157,7 +157,3 @@ class MailSenderTest(unittest.TestCase):
context = factory.buildProtocol("test@scrapy.org").context
self.assertIsInstance(context, ClientTLSOptions)
if __name__ == "__main__":
unittest.main()

View File

@ -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()

View File

@ -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()

View File

@ -177,7 +177,3 @@ class FeedExportConfigTestCase(unittest.TestCase):
"item_export_kwargs": {},
},
)
if __name__ == "__main__":
unittest.main()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -295,7 +295,3 @@ Disallow: /forum/active/
)
self.assertEqual(list(s), [{"loc": "http://127.0.0.1:8000/"}])
if __name__ == "__main__":
unittest.main()

View File

@ -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()

View File

@ -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()

View File

@ -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()