From 96a6939b6c53d20872cf0f2e21bf252edebb06d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20K=C3=A1rolyi?= Date: Mon, 13 Apr 2020 21:55:54 +0200 Subject: [PATCH] Add test for testing datadir not in sdist --- tests/test_install.py | 10 ++++++++++ validate_email/updater.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_install.py b/tests/test_install.py index 1bbecce..354ecbe 100644 --- a/tests/test_install.py +++ b/tests/test_install.py @@ -1,5 +1,7 @@ from pathlib import Path from subprocess import check_output +from tarfile import TarInfo +from tarfile import open as tar_open from unittest.case import TestCase try: @@ -26,3 +28,11 @@ class InstallTest(TestCase): self.assertTrue( expr=Path(etag_path).exists(), msg=f'{etag_path!r} doesn\'t exist.') + + def test_sdist_excludes_datadir(self): + 'The created sdist should not contain the data dir.' + latest_sdist = list(Path('dist').glob(pattern='*.tar.gz'))[-1] + tar_file = tar_open(name=latest_sdist, mode='r:gz') + for tarinfo in tar_file: # type: TarInfo + self.assertNotIn( + member='/validate_email/data/', container=tarinfo.name) diff --git a/validate_email/updater.py b/validate_email/updater.py index e430f54..c561200 100644 --- a/validate_email/updater.py +++ b/validate_email/updater.py @@ -119,7 +119,7 @@ class BlacklistUpdater(object): except HTTPError as exc: if exc.code == 304: # Not modified, update date on the tmp file - LOGGER.debug(msg=f'Local file is fresh enough (same ETag).') + LOGGER.debug(msg='Local file is fresh enough (same ETag).') BLACKLIST_FILEPATH_TMP.touch() return raise