From 9b4fba451bed2cde2ce3f2dea24ad16a669e8c1f Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Sun, 4 Mar 2018 07:54:41 -0500 Subject: [PATCH] more markers Signed-off-by: Kenneth Reitz --- .travis.yml | 2 ++ tests/test_project.py | 9 +++++++++ tests/test_utils.py | 17 +++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/.travis.yml b/.travis.yml index 015948a5..d705013f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,8 @@ env: - TEST_SUITE='dotvenv check unused' - TEST_SUITE='requirements' - TEST_SUITE='complex' + - TEST_SUITE='project' + - TEST_SUITE='utils' # - "pypy" # too many cache issues # - "3.7-dev" # no need, slows down builds # - "pypy3" # TODO: pkg_config issues diff --git a/tests/test_project.py b/tests/test_project.py index d9a632b8..7b0d3895 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -1,5 +1,6 @@ import os +import pytest import pipenv.project import pipenv.core from pipenv.vendor import delegator @@ -7,16 +8,19 @@ from pipenv.vendor import delegator class TestProject(): + @pytest.mark.project def test_proper_names(self): proj = pipenv.project.Project() assert proj.virtualenv_location in proj.proper_names_location assert isinstance(proj.proper_names, list) + @pytest.mark.project def test_download_location(self): proj = pipenv.project.Project() assert proj.virtualenv_location in proj.download_location assert proj.download_location.endswith('downloads') + @pytest.mark.project def test_create_pipfile(self): proj = pipenv.project.Project(which=pipenv.core.which) @@ -52,6 +56,7 @@ class TestProject(): assert config_source_2['name'] == 'pip_index_1' assert config_source_2['verify_ssl'] is True + @pytest.mark.project def test_parsed_pipfile(self): proj = pipenv.project.Project() @@ -76,6 +81,7 @@ class TestProject(): assert 'packages' in pfile assert 'socks' in pfile['packages']['requests']['extras'] + @pytest.mark.project def test_add_package_to_pipfile(self): proj = pipenv.project.Project() @@ -107,6 +113,7 @@ class TestProject(): assert 'click-completion' in p['packages'] assert p['packages']['click-completion'] == '*' + @pytest.mark.project def test_remove_package_from_pipfile(self): proj = pipenv.project.Project() @@ -139,6 +146,7 @@ class TestProject(): # assert 'dev-packages' not in p + @pytest.mark.project def test_internal_pipfile(self): proj = pipenv.project.Project() @@ -161,6 +169,7 @@ class TestProject(): delegator.run('rm -fr test_internal_pipfile') + @pytest.mark.project def test_internal_lockfile(self): proj = pipenv.project.Project() diff --git a/tests/test_utils.py b/tests/test_utils.py index f25b1936..8e748cd1 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -11,6 +11,7 @@ class TestUtils: """Test utility functions in pipenv""" + @pytest.mark.utils def test_convert_deps_to_pip(self): # requests = '*' @@ -63,6 +64,7 @@ class TestUtils: deps = pipenv.utils.convert_deps_to_pip(deps, r=False) assert deps[0] == 'django==1.10' + @pytest.mark.utils def test_convert_from_pip(self): # requests @@ -107,6 +109,7 @@ class TestUtils: dep = pipenv.utils.convert_deps_from_pip(dep) assert 'pipenv requires an #egg fragment for vcs' in str(e) + @pytest.mark.utils @pytest.mark.parametrize('version, specified_ver, expected', [ ('*', '*', True), ('2.1.6', '==2.1.4', False), @@ -117,6 +120,7 @@ class TestUtils: def test_is_required_version(self, version, specified_ver, expected): assert pipenv.utils.is_required_version(version, specified_ver) is expected + @pytest.mark.utils @pytest.mark.parametrize('entry, expected', [ ({'git': 'package.git', 'ref': 'v0.0.1'}, True), ({'hg': 'https://package.com/package', 'ref': 'v1.2.3'}, True), @@ -131,6 +135,7 @@ class TestUtils: def test_is_vcs(self, entry, expected): assert pipenv.utils.is_vcs(entry) is expected + @pytest.mark.utils def test_split_file(self): pipfile_dict = { 'packages': { @@ -153,12 +158,15 @@ class TestUtils: assert 'click' in split_dict['dev-packages-vcs'] assert 'crayons' in split_dict['dev-packages-vcs'] + @pytest.mark.utils def test_python_version_from_bad_path(self): assert pipenv.utils.python_version("/fake/path") is None + @pytest.mark.utils def test_python_version_from_non_python(self): assert pipenv.utils.python_version("/dev/null") is None + @pytest.mark.utils @pytest.mark.parametrize('version_output, version', [ ('Python 3.6.2', '3.6.2'), ('Python 3.6.2 :: Continuum Analytics, Inc.', '3.6.2'), @@ -171,6 +179,7 @@ class TestUtils: mocked_delegator.return_value = run_ret assert pipenv.utils.python_version('some/path') == version + @pytest.mark.utils @pytest.mark.windows @pytest.mark.skipif(os.name != 'nt', reason='Windows test only') def test_windows_shellquote(self): @@ -178,12 +187,14 @@ class TestUtils: expected_path = '"C:\\\\Program Files\\\\Python36\\\\python.exe"' assert pipenv.utils.shellquote(test_path) == expected_path + @pytest.mark.utils def test_is_valid_url(self): url = "https://github.com/kennethreitz/requests.git" not_url = "something_else" assert pipenv.utils.is_valid_url(url) assert pipenv.utils.is_valid_url(not_url) is False + @pytest.mark.utils @pytest.mark.parametrize('input_path, expected', [ ('artifacts/file.zip', './artifacts/file.zip'), ('./artifacts/file.zip', './artifacts/file.zip'), @@ -193,6 +204,7 @@ class TestUtils: def test_nix_converted_relative_path(self, input_path, expected): assert pipenv.utils.get_converted_relative_path(input_path) == expected + @pytest.mark.utils @pytest.mark.parametrize('input_path, expected', [ ('artifacts/file.zip', '.\\artifacts\\file.zip'), ('./artifacts/file.zip', '.\\artifacts\\file.zip'), @@ -202,6 +214,7 @@ class TestUtils: def test_win_converted_relative_path(self, input_path, expected): assert pipenv.utils.get_converted_relative_path(input_path) == expected + @pytest.mark.utils def test_download_file(self): url = "https://github.com/kennethreitz/pipenv/blob/master/README.rst" output = "test_download.rst" @@ -209,6 +222,7 @@ class TestUtils: assert os.path.exists(output) os.remove(output) + @pytest.mark.utils def test_new_line_end_of_toml_file(this): # toml file that needs clean up toml = """ @@ -227,6 +241,7 @@ twine = "*" # testing if the end of the generated file contains a newline assert new_toml[-1] == '\n' + @pytest.mark.utils @pytest.mark.parametrize('input_path, expected', [ ('c:\\Program Files\\Python36\\python.exe', 'C:\\Program Files\\Python36\\python.exe'), @@ -241,6 +256,7 @@ twine = "*" def test_win_normalize_drive(self, input_path, expected): assert pipenv.utils.normalize_drive(input_path) == expected + @pytest.mark.utils @pytest.mark.parametrize('input_path, expected', [ ('/usr/local/bin/python', '/usr/local/bin/python'), ('artifacts/file.zip', 'artifacts/file.zip'), @@ -251,6 +267,7 @@ twine = "*" def test_nix_normalize_drive(self, input_path, expected): assert pipenv.utils.normalize_drive(input_path) == expected + @pytest.mark.utils @pytest.mark.requirements def test_get_requirements(self): # Test eggs in URLs