When running tests within a Tox environment with pinned dependencies, make sure that the version of Twisted is the pinned version. See https://github.com/scrapy/scrapy/pull/4814#issuecomment-706230011
(self)
| 9 | |
| 10 | class TestScrapyUtils: |
| 11 | def test_pinned_twisted_version(self): |
| 12 | """When running tests within a Tox environment with pinned |
| 13 | dependencies, make sure that the version of Twisted is the pinned |
| 14 | version. |
| 15 | |
| 16 | See https://github.com/scrapy/scrapy/pull/4814#issuecomment-706230011 |
| 17 | """ |
| 18 | if not os.environ.get("_SCRAPY_PINNED", None): |
| 19 | pytest.skip("Not in a pinned environment") |
| 20 | |
| 21 | tox_config_file_path = Path(__file__).parent / ".." / "tox.ini" |
| 22 | config_parser = ConfigParser() |
| 23 | config_parser.read(tox_config_file_path) |
| 24 | pattern = r"Twisted==([\d.]+)" |
| 25 | match = re.search(pattern, config_parser["pinned"]["deps"]) |
| 26 | pinned_twisted_version_string = match[1] |
| 27 | |
| 28 | assert twisted_version.short() == pinned_twisted_version_string |