From bff570ec2e991ca8fb8b4ddc5ae262c4672a95c4 Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Sat, 21 Sep 2019 22:02:15 +0200 Subject: [PATCH] tests: Use pytest, separate dev dependencies * Use pytest instead of nosetests * Move all dev-related dependencies to `dev-dependencies` and hence minimize the footprint. Signed-off-by: mr.Shu --- .travis.yml | 2 +- poetry.lock | 37 +++++++++++++++++++++++++++++-------- pyproject.toml | 4 ++-- tests/test_envtoml.py | 32 ++++++++++++-------------------- 4 files changed, 44 insertions(+), 31 deletions(-) diff --git a/.travis.yml b/.travis.yml index a9d3cb3..f800030 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,6 @@ before_install: install: - poetry install script: - - poetry run nosetests --with-coverage --cover-package=envtoml + - poetry run pytest --cov=envtoml after_success: - coveralls diff --git a/poetry.lock b/poetry.lock index 9f27c78..f5c4503 100644 --- a/poetry.lock +++ b/poetry.lock @@ -24,7 +24,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" version = "0.4.1" [[package]] -category = "main" +category = "dev" description = "Code coverage measurement for Python" name = "coverage" optional = false @@ -52,12 +52,16 @@ python-versions = ">=3.4" version = "7.2.0" [[package]] -category = "main" -description = "nose extends unittest to make testing easier" -name = "nose" +category = "dev" +description = "Object-oriented filesystem paths" +marker = "python_version < \"3.6\"" +name = "pathlib2" optional = false python-versions = "*" -version = "1.3.7" +version = "2.3.4" + +[package.dependencies] +six = "*" [[package]] category = "dev" @@ -98,6 +102,22 @@ py = ">=1.5.0" setuptools = "*" six = ">=1.10.0" +[package.dependencies.pathlib2] +python = "<3.6" +version = ">=2.2.0" + +[[package]] +category = "dev" +description = "Pytest plugin for measuring coverage." +name = "pytest-cov" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "2.7.1" + +[package.dependencies] +coverage = ">=4.4" +pytest = ">=3.6" + [[package]] category = "dev" description = "Python 2 and 3 compatibility utilities" @@ -127,8 +147,8 @@ version = "0.6.0" more-itertools = "*" [metadata] -content-hash = "49e59ad9601ee8349cee48460ac9a86360b1a2361be4a114432b261801d3adbc" -python-versions = "^3.7" +content-hash = "3d72aef154f1018601068b0600107a415cb426626ee31817d5c25e2df2691951" +python-versions = "^3.5" [metadata.hashes] atomicwrites = ["03472c30eb2c5d1ba9227e4c2ca66ab8287fbfbbda3888aa93dc2e28fc6811b4", "75a9445bac02d8d058d5e1fe689654ba5a6556a1dfd8ce6ec55a0ed79866cfa6"] @@ -137,10 +157,11 @@ colorama = ["05eed71e2e327246ad6b38c540c4a3117230b19679b875190486ddd2d721422d", coverage = ["08907593569fe59baca0bf152c43f3863201efb6113ecb38ce7e97ce339805a6", "0be0f1ed45fc0c185cfd4ecc19a1d6532d72f86a2bac9de7e24541febad72650", "141f08ed3c4b1847015e2cd62ec06d35e67a3ac185c26f7635f4406b90afa9c5", "19e4df788a0581238e9390c85a7a09af39c7b539b29f25c89209e6c3e371270d", "23cc09ed395b03424d1ae30dcc292615c1372bfba7141eb85e11e50efaa6b351", "245388cda02af78276b479f299bbf3783ef0a6a6273037d7c60dc73b8d8d7755", "331cb5115673a20fb131dadd22f5bcaf7677ef758741312bee4937d71a14b2ef", "386e2e4090f0bc5df274e720105c342263423e77ee8826002dcffe0c9533dbca", "3a794ce50daee01c74a494919d5ebdc23d58873747fa0e288318728533a3e1ca", "60851187677b24c6085248f0a0b9b98d49cba7ecc7ec60ba6b9d2e5574ac1ee9", "63a9a5fc43b58735f65ed63d2cf43508f462dc49857da70b8980ad78d41d52fc", "6b62544bb68106e3f00b21c8930e83e584fdca005d4fffd29bb39fb3ffa03cb5", "6ba744056423ef8d450cf627289166da65903885272055fb4b5e113137cfa14f", "7494b0b0274c5072bddbfd5b4a6c6f18fbbe1ab1d22a41e99cd2d00c8f96ecfe", "826f32b9547c8091679ff292a82aca9c7b9650f9fda3e2ca6bf2ac905b7ce888", "93715dffbcd0678057f947f496484e906bf9509f5c1c38fc9ba3922893cda5f5", "9a334d6c83dfeadae576b4d633a71620d40d1c379129d587faa42ee3e2a85cce", "af7ed8a8aa6957aac47b4268631fa1df984643f07ef00acd374e456364b373f5", "bf0a7aed7f5521c7ca67febd57db473af4762b9622254291fbcbb8cd0ba5e33e", "bf1ef9eb901113a9805287e090452c05547578eaab1b62e4ad456fcc049a9b7e", "c0afd27bc0e307a1ffc04ca5ec010a290e49e3afbe841c5cafc5c5a80ecd81c9", "dd579709a87092c6dbee09d1b7cfa81831040705ffa12a1b248935274aee0437", "df6712284b2e44a065097846488f66840445eb987eb81b3cc6e4149e7b6982e1", "e07d9f1a23e9e93ab5c62902833bf3e4b1f65502927379148b6622686223125c", "e2ede7c1d45e65e209d6093b762e98e8318ddeff95317d07a27a2140b80cfd24", "e4ef9c164eb55123c62411f5936b5c2e521b12356037b6e1c2617cef45523d47", "eca2b7343524e7ba246cab8ff00cab47a2d6d54ada3b02772e908a45675722e2", "eee64c616adeff7db37cc37da4180a3a5b6177f5c46b187894e633f088fb5b28", "ef824cad1f980d27f26166f86856efe11eff9912c4fed97d3804820d43fa550c", "efc89291bd5a08855829a3c522df16d856455297cf35ae827a37edac45f466a7", "fa964bae817babece5aa2e8c1af841bebb6d0b9add8e637548809d040443fee0", "ff37757e068ae606659c28c3bd0d923f9d29a85de79bf25b2b34b148473b5025"] importlib-metadata = ["aa18d7378b00b40847790e7c27e11673d7fed219354109d0e7b9e5b25dc3ad26", "d5f18a79777f3aa179c145737780282e27b508fc8fd688cb17c7a813e8bd39af"] more-itertools = ["409cd48d4db7052af495b09dec721011634af3753ae1ef92d2b32f73a745f832", "92b8c4b06dac4f0611c0729b2f2ede52b2e1bac1ab48f089c7ddc12e26bb60c4"] -nose = ["9ff7c6cc443f8c51994b34a667bbcf45afd6d945be7477b52e97516fd17c53ac", "dadcddc0aefbf99eea214e0f1232b94f2fa9bd98fa8353711dacb112bfcbbb2a", "f1bffef9cbc82628f6e7d7b40d7e255aefaa1adb6a1b1d26c69a8b79e6208a98"] +pathlib2 = ["2156525d6576d21c4dcaddfa427fae887ef89a7a9de5cbfe0728b3aafa78427e", "446014523bb9be5c28128c4d2a10ad6bb60769e78bd85658fe44a450674e0ef8"] pluggy = ["0db4b7601aae1d35b4a033282da476845aa19185c1e6964b25cf324b5e4ec3e6", "fa5fa1622fa6dd5c030e9cad086fa19ef6a0cf6d7a2d12318e10cb49d6d68f34"] py = ["64f65755aee5b381cea27766a3a147c3f15b9b6b9ac88676de66ba2ae36793fa", "dc639b046a6e2cff5bbe40194ad65936d6ba360b52b3c3fe1d08a82dd50b5e53"] pytest = ["3f193df1cfe1d1609d4c583838bea3d532b18d6160fd3f55c9447fdca30848ec", "e246cf173c01169b9617fc07264b7b1316e78d7a650055235d6d897bc80d9660"] +pytest-cov = ["2b097cde81a302e1047331b48cadacf23577e431b61e9c6f49a1170bbe3d3da6", "e00ea4fdde970725482f1f35630d12f074e121a23801aabf2ae154ec6bdd343a"] six = ["3350809f0555b11f552448330d0b52d5f24c91a322ea4a15ef22629740f3761c", "d16a0141ec1a18405cd4ce8b4613101da75da0e9a7aec5bdd4fa804d0e0eba73"] toml = ["229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", "235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e", "f1db651f9657708513243e61e6cc67d101a39bad662eaa9b5546f789338e07a3"] zipp = ["3718b1cbcd963c7d4c5511a8240812904164b7f381b647143a89d3b98f9bcd8e", "f06903e9f1f43b12d371004b4ac7b06ab39a44adc747266928ae6debfa7b3335"] diff --git a/pyproject.toml b/pyproject.toml index 639a65b..a53bc1e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,11 +16,11 @@ classifiers = [ [tool.poetry.dependencies] python = "^3.5" toml = "^0.10.0" -nose = "^1.3" -coverage = "^4.5" [tool.poetry.dev-dependencies] pytest = "^3.0" +coverage = "^4.5" +pytest-cov = "^2.7" [build-system] requires = ["poetry>=0.12"] diff --git a/tests/test_envtoml.py b/tests/test_envtoml.py index 14838e2..4dc513b 100644 --- a/tests/test_envtoml.py +++ b/tests/test_envtoml.py @@ -1,6 +1,5 @@ from envtoml import __version__ from envtoml import load, loads -from nose.tools import assert_equals import os @@ -22,45 +21,40 @@ def test_version(): def test_load(): - assert_equals(load(open('./tests/test_simple.toml')), SIMPLE_OUTPUT) - assert_equals(load(open('./tests/test_complex.toml')), MORE_COMPLEX_OUTPUT) + assert load(open('./tests/test_simple.toml')) == SIMPLE_OUTPUT + assert load(open('./tests/test_complex.toml')) == MORE_COMPLEX_OUTPUT def test_load_with_replace(): os.environ['MY_CONFIG_VAR'] = "10" - assert_equals(load(open('./tests/test_simple_replacement.toml')), - SIMPLE_OUTPUT) + assert load(open('./tests/test_simple_replacement.toml')) == SIMPLE_OUTPUT def test_loads(): - assert_equals(loads('{x = 5, y = 10}'), SIMPLE_OUTPUT) + assert loads('{x = 5, y = 10}') == SIMPLE_OUTPUT def test_loads_with_replace(): os.environ['MY_CONFIG_VAR'] = "10" - assert_equals(loads("{x = 5, y = '$MY_CONFIG_VAR'}"), SIMPLE_OUTPUT) + assert loads("{x = 5, y = '$MY_CONFIG_VAR'}") == SIMPLE_OUTPUT def test_loads_with_replace_str(): os.environ['MY_STR_CONFIG_VAR'] = "Hello" - assert_equals(loads("{name = '$MY_STR_CONFIG_VAR'}"), - {'name': 'Hello'}) + assert loads("{name = '$MY_STR_CONFIG_VAR'}") == {'name': 'Hello'} def test_loads_with_replace_float(): os.environ['MY_FLOAT_CONFIG_VAR'] = "3.14" - assert_equals(loads("{val = '$MY_FLOAT_CONFIG_VAR'}"), - {'val': 3.14}) + assert loads("{val = '$MY_FLOAT_CONFIG_VAR'}") == {'val': 3.14} def test_loads_with_replace_bool(): os.environ['MY_BOOL_CONFIG_VAR'] = 'true' - assert_equals(loads("{is_set = '$MY_BOOL_CONFIG_VAR'}"), - {'is_set': True}) + assert loads("{is_set = '$MY_BOOL_CONFIG_VAR'}") == {'is_set': True} os.environ['MY_BOOL_CONFIG_VAR'] = 'false' - assert_equals(loads("{is_set = '$MY_BOOL_CONFIG_VAR'}"), - {'is_set': False}) + assert loads("{is_set = '$MY_BOOL_CONFIG_VAR'}") == {'is_set': False} def test_complex_replacement(): @@ -68,15 +62,13 @@ def test_complex_replacement(): os.environ['MY_LAPTOP_PRICE'] = '1000' os.environ['MY_IS_LAPTOP_SOLD'] = 'true' - assert_equals(load(open('./tests/test_complex_replacement.toml')), - MORE_COMPLEX_OUTPUT) + assert load(open('./tests/test_complex_replacement.toml')) == MORE_COMPLEX_OUTPUT # noqa def test_loads_with_replace_and_empty_value(): - assert_equals(loads("{x = 5, y = '$NON_EXISTENT_VAR'}"), {'x': 5, 'y': ''}) + assert loads("{x = 5, y = '$NON_EXISTENT_VAR'}") == {'x': 5, 'y': ''} def test_loads_with_replace_dict(): os.environ['MY_CONFIG_VAR'] = "{z = 123}" - assert_equals(loads("{x = 5, y = '$MY_CONFIG_VAR'}"), - {'x': 5, 'y': {'z': 123}}) + assert loads("{x = 5, y = '$MY_CONFIG_VAR'}") == {'x': 5, 'y': {'z': 123}}