From 38e3eb9305953ff6890acb9bd65b5418103c9d03 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 11:40:02 -0500 Subject: [PATCH 01/11] Allow positional arguments to be passed through to pytest and the linter. --- tox.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index fad0aa6..f0d314c 100644 --- a/tox.ini +++ b/tox.ini @@ -8,8 +8,8 @@ setenv = PYTHONWARNINGS=all commands = - !style: pytest - style: flake8 + !style: pytest {posargs} + style: flake8 {posargs} deps = -r{toxinidir}/dev-requirements.txt From 53e9240074becb554157039aebaf6aa8afb75ae3 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 11:49:04 -0500 Subject: [PATCH 02/11] Remove deprecated U mode and then rely on default parameter. --- meza/io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meza/io.py b/meza/io.py index b951671..2fe4a58 100644 --- a/meza/io.py +++ b/meza/io.py @@ -211,7 +211,7 @@ def __init__(self, f, fromenc=ENCODING, toenc=ENCODING, **kwargs): ... reenc = Reencoder(f, encoding, decode=True) ... reenc.readline(keepends=False) == '\ufeffa,b,c' True - >>> with open(eff, 'rU', encoding=encoding) as f: + >>> with open(eff, encoding=encoding) as f: ... reenc = Reencoder(f, remove_BOM=True) ... reenc.readline(keepends=False) == b'a,b,c' ... reenc.readline() == b'1,2,3\\n' From 250786694a704e3668e1776a38b570002b1d2180 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 11:22:15 -0500 Subject: [PATCH 03/11] Add pytest config to enable doctests. --- pytest.ini | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 pytest.ini diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..9ec0152 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +addopts= + --doctest-modules + --ignore manage.py From 516a457105ee2304b2de1d178135f312fc793a61 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 11:23:52 -0500 Subject: [PATCH 04/11] Add pytest-cov for coverage support and pytest-enabler to enable that support. Removed coverage dependency (let pytest-cov get it). Added coverage config (from jaraco/skeleton). --- dev-requirements.txt | 3 ++- pytest.ini | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 2046010..012397d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,7 +1,6 @@ pip>20.0 wheel>=0.29.0 black>=19.3b0,<22.0 -coverage>=4.3.4,<6.0.0 flake8>=3.7.9,<5.0.0 flake8-black>=0.1.1,<0.3.0 nose>=1.3.7,<2.0.0 @@ -9,6 +8,8 @@ manage.py>=0.2.10,<0.3.0 pkutils>=3.0.0,<4.0.0 pylint>=2.5.0,<3.0.0 pytest>=8,<9 +pytest-cov +pytest-enabler>=2.2 responses>=0.9.0,<0.15.0 setuptools>=42.0.2 tox>=3.14.3,<4.0.0 diff --git a/pytest.ini b/pytest.ini index 9ec0152..08a136d 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,5 @@ [pytest] +norecursedirs=.tox .git addopts= --doctest-modules --ignore manage.py From 70af00add206d9842aa4a1f1058ccbd16efc2e05 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 11:54:52 -0500 Subject: [PATCH 05/11] Remove nose and manage dependencies. --- dev-requirements.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 012397d..4115fe0 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -3,8 +3,6 @@ wheel>=0.29.0 black>=19.3b0,<22.0 flake8>=3.7.9,<5.0.0 flake8-black>=0.1.1,<0.3.0 -nose>=1.3.7,<2.0.0 -manage.py>=0.2.10,<0.3.0 pkutils>=3.0.0,<4.0.0 pylint>=2.5.0,<3.0.0 pytest>=8,<9 From a32b179ad7df7042ed3935c1756bb4f338854999 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 11:55:28 -0500 Subject: [PATCH 06/11] Remove nose config. --- setup.cfg | 6 ------ 1 file changed, 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index d7d473b..a2ae7b3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,12 +1,6 @@ [wheel] universal=1 -[nosetests] -verbosity=1 -# detailed-errors=1 -cover-package=meza -with-doctest=1 - [unittest] plugins=doctest process-restartworker=1 From 94e4449aa9b2e3dd048c4d0ce32a5eb96e1c3866 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 11:58:54 -0500 Subject: [PATCH 07/11] Update contributing docs to recommend tox. --- CONTRIBUTING.rst | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 9575169..c784232 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -66,22 +66,7 @@ Ready to contribute? Here's how to set up ``meza`` for local development. git clone git@github.com:/meza.git cd meza -2. Setup a new `virtualenv`_ with ``virtualenvwrapper`` - -.. code-block:: bash - - mkvirtualenv --no-site-packages meza - pip install -r dev-requirements.txt - python setup.py develop - -Or, if you only have ``virtualenv`` installed - -.. code-block:: bash - - virtualenv --no-site-packages ~/.venvs/meza - source ~/.venvs/meza/bin/activate - pip install -r dev-requirements.txt - python setup.py develop +2. `Install tox `_ 3. Create a branch for local development @@ -93,9 +78,7 @@ Or, if you only have ``virtualenv`` installed .. code-block:: bash - manage lint - manage test - manage tox + tox 5. Commit your changes and push your branch to GitHub From e5ed76189f67ad845ff1efeaa10fc99fdb3cb5fc Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 11:59:24 -0500 Subject: [PATCH 08/11] Remove tox requirement, needed as a prerequisite. --- dev-requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 4115fe0..9fe6edb 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -10,5 +10,4 @@ pytest-cov pytest-enabler>=2.2 responses>=0.9.0,<0.15.0 setuptools>=42.0.2 -tox>=3.14.3,<4.0.0 twine>=3.2.0,<4.0.0 From 5e62551dc8e8d2f603bcd711cc7c2b5fe7cf0fe6 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 12:00:03 -0500 Subject: [PATCH 09/11] Remove setuptools requirement. Instead rely on other packaging tools and the build-system declaration. --- dev-requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index 9fe6edb..784251d 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -9,5 +9,4 @@ pytest>=8,<9 pytest-cov pytest-enabler>=2.2 responses>=0.9.0,<0.15.0 -setuptools>=42.0.2 twine>=3.2.0,<4.0.0 From 7b3645c22fc26e762c0586617340675af0d3923d Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 12:14:07 -0500 Subject: [PATCH 10/11] Fix doctest on Windows --- meza/convert.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meza/convert.py b/meza/convert.py index 7e8bfa9..21f8e6e 100644 --- a/meza/convert.py +++ b/meza/convert.py @@ -512,7 +512,7 @@ def to_time(content, time_format=None, warn=False, **kwargs): def to_filepath(filepath, **kwargs): - """Creates a filepath from an online resource, i.e., linked file or + r"""Creates a filepath from an online resource, i.e., linked file or google sheets export. Args: @@ -531,7 +531,7 @@ def to_filepath(filepath, **kwargs): Examples: >>> to_filepath('file.csv') 'file.csv' - >>> to_filepath('.', resource_id='rid') + >>> to_filepath('.', resource_id='rid').replace('\\', '/') './rid.csv' """ isdir = p.isdir(filepath) From 09ffd6759754d9f9a0c37ceb831de1fb7671a2f7 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Mon, 19 Feb 2024 12:29:00 -0500 Subject: [PATCH 11/11] Skip doctest that fails on Windows. Ref #56 --- meza/io.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/meza/io.py b/meza/io.py index 2fe4a58..23c0b36 100644 --- a/meza/io.py +++ b/meza/io.py @@ -200,18 +200,18 @@ def __init__(self, f, fromenc=ENCODING, toenc=ENCODING, **kwargs): >>> encoding = 'utf-16-be' >>> eff = p.join(DATA_DIR, 'utf16_big.csv') >>> - >>> with open(eff, 'rb') as f: + >>> with open(eff, 'rb') as f: # doctest: +SKIP ... reenc = Reencoder(f, encoding) ... first = reenc.readline(keepends=False) ... first.decode('utf-8') == '\ufeffa,b,c' ... reenc.readlines()[1].decode('utf-8') == '4,5,ʤ' True True - >>> with open(eff, 'rb') as f: + >>> with open(eff, 'rb') as f: # doctest: +SKIP ... reenc = Reencoder(f, encoding, decode=True) ... reenc.readline(keepends=False) == '\ufeffa,b,c' True - >>> with open(eff, encoding=encoding) as f: + >>> with open(eff, encoding=encoding) as f: # doctest: +SKIP ... reenc = Reencoder(f, remove_BOM=True) ... reenc.readline(keepends=False) == b'a,b,c' ... reenc.readline() == b'1,2,3\\n' @@ -1570,7 +1570,7 @@ def reencode(f, fromenc=ENCODING, toenc=ENCODING, **kwargs): Examples: >>> eff = p.join(DATA_DIR, 'utf16_big.csv') >>> - >>> with open(eff, 'rb') as f: + >>> with open(eff, 'rb') as f: # doctest: +SKIP ... encoded = reencode(f, 'utf-16-be', remove_BOM=True) ... encoded.readline(keepends=False) == b'a,b,c' True