From e3d2bf24c725d226bad362bce089e2fd3a07798b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20K=C3=A1rolyi?= Date: Sun, 12 Apr 2020 20:04:32 +0200 Subject: [PATCH] Add a test for preinstalled data directory checking --- .travis.yml | 3 ++- tests/test_install.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/test_install.py diff --git a/.travis.yml b/.travis.yml index 169e7ea..efc20d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,8 @@ install: - python -m pip install -U pip wheel setuptools - python -m pip install -U isort flake8 - python -m pip install -r requirements.txt - - python -m pip install -e . + - python -Wd setup.py sdist + - python -Wd -m pip install dist/py3-validate-email-*.tar.gz # command to run tests script: diff --git a/tests/test_install.py b/tests/test_install.py new file mode 100644 index 0000000..1bbecce --- /dev/null +++ b/tests/test_install.py @@ -0,0 +1,28 @@ +from pathlib import Path +from subprocess import check_output +from unittest.case import TestCase + +try: + # OSX Homebrew fix: https://stackoverflow.com/a/53190037/1067833 + from sys import _base_executable as executable +except ImportError: + from sys import executable + + +class InstallTest(TestCase): + 'Testing package installation.' + + def test_datadir_is_in_place(self): + 'Data directory should be in the virtualenv.' + output = check_output([ + executable, '-c', ( + 'import sys;sys.path.remove("");import validate_email;' + 'print(validate_email.updater.BLACKLIST_FILEPATH_INSTALLED);' + 'print(validate_email.updater.ETAG_FILEPATH_INSTALLED, end="")' + )]).decode('ascii') + bl_path, etag_path = output.split('\n') + self.assertTrue( + expr=Path(bl_path).exists(), msg=f'{bl_path!r} doesn\'t exist.') + self.assertTrue( + expr=Path(etag_path).exists(), + msg=f'{etag_path!r} doesn\'t exist.')