From b8c9803ce5c06b7b044585b86c38270783aeb4ad Mon Sep 17 00:00:00 2001 From: Zero Date: Thu, 11 Aug 2022 11:58:19 +0800 Subject: [PATCH 01/31] Set dependency latest version env --- ci/envs/latest.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 ci/envs/latest.yaml diff --git a/ci/envs/latest.yaml b/ci/envs/latest.yaml new file mode 100644 index 000000000..4605ab71f --- /dev/null +++ b/ci/envs/latest.yaml @@ -0,0 +1,30 @@ +name: pyjanitor-dev +channels: + - conda-forge +dependencies: + # required + - pandas + - pandas-flavor + - multipledispatch + - scipy + + # optional + - biopython + - natsort + - pyspark + - rdkit + - tqdm + - unyt + - xarray + - numba + # io + - openpyxl + - xlrd + + # testing + - pytest + - pytest-cov + - pytest-xdist + - hypothesis + - pandas-vet + - interrogate From a61d3c4a3db5f97515bd45a80ad0c00a5790cbee Mon Sep 17 00:00:00 2001 From: Zero Date: Thu, 11 Aug 2022 12:26:49 +0800 Subject: [PATCH 02/31] Add marks --- ci/envs/latest.yaml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ci/envs/latest.yaml b/ci/envs/latest.yaml index 4605ab71f..df9466ae0 100644 --- a/ci/envs/latest.yaml +++ b/ci/envs/latest.yaml @@ -6,17 +6,18 @@ dependencies: - pandas - pandas-flavor - multipledispatch - - scipy + - scipy # math, functions # optional - - biopython - - natsort - - pyspark - - rdkit - - tqdm - - unyt + - natsort # functions + - numba # functions + - biopython # biology + - rdkit # chemistry + - tqdm # chemistry + - unyt # engineering + - requests # finance + - pyspark>=3.2.0 - xarray - - numba # io - openpyxl - xlrd From 9986e8ea3a9e5737a86158b76bc0c8be23ba0d5c Mon Sep 17 00:00:00 2001 From: Zero Date: Thu, 11 Aug 2022 12:36:01 +0800 Subject: [PATCH 03/31] Test latest env --- .github/workflows/tests.yml | 43 ++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4b9ceb91c..3e1305dd5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,21 +1,33 @@ -name: pyjanitor tests +name: unit tests on: [pull_request] jobs: run-tests: - strategy: - fail-fast: false - matrix: - test-subset: ["turtle", "not turtle"] - runs-on: ubuntu-latest - name: Run pyjanitor test suite + name: ${{ matrix.os }}, ${{ matrix.python-version }}, ${{ matrix.env }} + runs-on: ${{ matrix.os }} # https://github.com/marketplace/actions/setup-miniconda#use-a-default-shell defaults: run: shell: bash -l {0} + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + dev: [false] + python-version: + - "3.6" + - "3.7" + - "3.8" + - "3.9" + - "3.10" + env: [ci/envs/latest.yaml] + steps: - name: Checkout repository uses: actions/checkout@v2 @@ -26,16 +38,17 @@ jobs: with: auto-update-conda: true miniforge-variant: Mambaforge - channels: conda-forge - activate-environment: pyjanitor-dev - environment-file: environment-dev.yml + environment-file: ${{ matrix.env }} use-mamba: true - - name: Run unit tests - run: | - conda activate pyjanitor-dev - python -m pip install -e . - pytest -m "${{ matrix.test-subset }}" + - name: Install PyJanitor + - run: python -m pip install -e . + + - name: Run not turtle unit tests + run: pytest -m "not turtle" + + - name: Run turtle unit tests + run: pytest -m "turtle" # https://github.com/codecov/codecov-action - name: Upload code coverage From 2c3899447e1e7ceefdd87decdd871edbaa578270 Mon Sep 17 00:00:00 2001 From: Zero Date: Thu, 11 Aug 2022 12:37:36 +0800 Subject: [PATCH 04/31] require minimal pyspark is 3.2.2 --- ci/envs/latest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/envs/latest.yaml b/ci/envs/latest.yaml index df9466ae0..1364e50c3 100644 --- a/ci/envs/latest.yaml +++ b/ci/envs/latest.yaml @@ -16,7 +16,7 @@ dependencies: - tqdm # chemistry - unyt # engineering - requests # finance - - pyspark>=3.2.0 + - pyspark>=3.2.2 - xarray # io - openpyxl From f71cefc4faf45d1f7991d37366d8a809dfcee8b2 Mon Sep 17 00:00:00 2001 From: Zero Date: Thu, 11 Aug 2022 12:46:16 +0800 Subject: [PATCH 05/31] update env name --- ci/envs/latest.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/envs/latest.yaml b/ci/envs/latest.yaml index 1364e50c3..b5002b78e 100644 --- a/ci/envs/latest.yaml +++ b/ci/envs/latest.yaml @@ -1,4 +1,4 @@ -name: pyjanitor-dev +name: pyjanitor-test channels: - conda-forge dependencies: From 5192b9001f79a25808d3966bc625a822842fc40f Mon Sep 17 00:00:00 2001 From: Zero Date: Thu, 11 Aug 2022 22:41:42 +0800 Subject: [PATCH 06/31] empty commit to trigger ci From 287ee5b90b6a8df601a0befbe382e200241d3472 Mon Sep 17 00:00:00 2001 From: Zero Date: Fri, 12 Aug 2022 08:58:48 +0800 Subject: [PATCH 07/31] remove duplicate `-` --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3e1305dd5..fded998c8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,7 +42,7 @@ jobs: use-mamba: true - name: Install PyJanitor - - run: python -m pip install -e . + run: python -m pip install -e . - name: Run not turtle unit tests run: pytest -m "not turtle" From 5b8a09ac101a034f8468578c750187509c1f3b62 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 20 Aug 2022 17:52:30 +0800 Subject: [PATCH 08/31] skip `test_docs_general_functions_present` only test documentation in documentation building CI --- tests/test_documentation_build.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 174c47777..136aa2e5c 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -1,8 +1,22 @@ """Tests for documentation build.""" -import os +import sys +import pytest +try: + import mkdocs +except ImportError: + ... + + +@pytest.mark.skipif( + "mkdocs" not in sys.modules, + reason=( + "Requires the MkDocs library. " + "And only test documentation in documentation building CI." + ), +) def test_docs_general_functions_present(): """Test that all docs pages build correctly. @@ -10,8 +24,6 @@ def test_docs_general_functions_present(): all of the functions are present in the docs. This is an awesome thing that we could use help with in the future. """ - # Build docs using mkdocs - os.system("mkdocs build --clean") # We want to check that the following keywords are all present. # I put in a subsample of general functions. From 90ce9f005241a65001b6404158cdb7cc58e181f8 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 20 Aug 2022 17:54:45 +0800 Subject: [PATCH 09/31] ignore flake --- tests/test_documentation_build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 136aa2e5c..3dd5f7e46 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -5,7 +5,7 @@ import pytest try: - import mkdocs + import mkdocs # noqa: F401 except ImportError: ... From f236624a3bcc36aa0e551bd22700480ed3d34b12 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 20 Aug 2022 17:59:12 +0800 Subject: [PATCH 10/31] still build the documentation --- tests/test_documentation_build.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 3dd5f7e46..b44be391f 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -1,5 +1,6 @@ """Tests for documentation build.""" +import os import sys import pytest @@ -25,6 +26,9 @@ def test_docs_general_functions_present(): This is an awesome thing that we could use help with in the future. """ + # Build docs using mkdocs + os.system("mkdocs build --clean") + # We want to check that the following keywords are all present. # I put in a subsample of general functions. # This can be made much more robust. From b155722392dc6e01805bfe91d96b87a7b4875eb1 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 20 Aug 2022 19:04:24 +0800 Subject: [PATCH 11/31] Update skipif logic --- tests/test_documentation_build.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index b44be391f..36131e12e 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -1,18 +1,22 @@ """Tests for documentation build.""" import os -import sys import pytest try: - import mkdocs # noqa: F401 -except ImportError: - ... + import mkdocs + # Even if 'mkdocs' is installed + # 'mkdocs' is could be imported as + # Need to check if 'mkdocs' has '__version__' attribute + + mkdocs_installed = hasattr(mkdocs, "__version__") +except (ImportError, AttributeError): + mkdocs_installed = False @pytest.mark.skipif( - "mkdocs" not in sys.modules, + not mkdocs_installed, reason=( "Requires the MkDocs library. " "And only test documentation in documentation building CI." From 5b751988001e7ff737dc5b6ad359f29ecc6c26e3 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 20 Aug 2022 19:08:15 +0800 Subject: [PATCH 12/31] test built result on 'build documentation' ci --- .github/workflows/docs-preview.yml | 3 +++ tests/test_documentation_build.py | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docs-preview.yml b/.github/workflows/docs-preview.yml index 77004dbe5..b01ae40ae 100644 --- a/.github/workflows/docs-preview.yml +++ b/.github/workflows/docs-preview.yml @@ -35,6 +35,9 @@ jobs: name: website path: site/ + - name: Test built result + run: pytest .\tests\test_documentation_build.py + - name: Deploy docs preview to Netlify uses: nwtgck/actions-netlify@v1.1 with: diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 36131e12e..6b1b26860 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -30,9 +30,6 @@ def test_docs_general_functions_present(): This is an awesome thing that we could use help with in the future. """ - # Build docs using mkdocs - os.system("mkdocs build --clean") - # We want to check that the following keywords are all present. # I put in a subsample of general functions. # This can be made much more robust. From 18f34e05266a4c8e84ed273042f598a83b26a825 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 20 Aug 2022 11:10:20 +0000 Subject: [PATCH 13/31] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_documentation_build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 6b1b26860..bc27b6890 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -6,6 +6,7 @@ try: import mkdocs + # Even if 'mkdocs' is installed # 'mkdocs' is could be imported as # Need to check if 'mkdocs' has '__version__' attribute From 263aaa212a5dc55a56f7a79932b5c08d3bff7ada Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 20 Aug 2022 19:10:55 +0800 Subject: [PATCH 14/31] lint code --- tests/test_documentation_build.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 6b1b26860..3be4ddfd8 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -1,7 +1,5 @@ """Tests for documentation build.""" -import os - import pytest try: From 4d266897f0aa7678b036f7c467b60876aea90cf0 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 20 Aug 2022 21:48:27 +0800 Subject: [PATCH 15/31] simplify a bit --- .github/workflows/docs-preview.yml | 2 +- pytest.ini | 1 + tests/test_documentation_build.py | 15 ++++++--------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/docs-preview.yml b/.github/workflows/docs-preview.yml index b01ae40ae..63449bf42 100644 --- a/.github/workflows/docs-preview.yml +++ b/.github/workflows/docs-preview.yml @@ -36,7 +36,7 @@ jobs: path: site/ - name: Test built result - run: pytest .\tests\test_documentation_build.py + run: pytest -m "documentation" - name: Deploy docs preview to Netlify uses: nwtgck/actions-netlify@v1.1 diff --git a/pytest.ini b/pytest.ini index 6dc77becf..d789b7276 100644 --- a/pytest.ini +++ b/pytest.ini @@ -12,4 +12,5 @@ markers = spark_functions: tests for pyspark functions xarray: tests for xarray functions timeseries: tests for timeseries + documentation: tests for documentation turtle: tests that take more than 5 seconds to execute diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index b0fb32d48..b2e734f7e 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -2,16 +2,12 @@ import pytest -try: - import mkdocs - # Even if 'mkdocs' is installed - # 'mkdocs' is could be imported as - # Need to check if 'mkdocs' has '__version__' attribute - - mkdocs_installed = hasattr(mkdocs, "__version__") -except (ImportError, AttributeError): - mkdocs_installed = False +# Even if 'mkdocs' is installed +# 'mkdocs' is could be imported as +# Need to check if 'mkdocs' has '__version__' attribute +mkdocs = pytest.importorskip("mkdocs") +mkdocs_installed = hasattr(mkdocs, "__version__") @pytest.mark.skipif( @@ -21,6 +17,7 @@ "And only test documentation in documentation building CI." ), ) +@pytest.mark.documentation def test_docs_general_functions_present(): """Test that all docs pages build correctly. From 4b1e2e93399232d890834ee514d21645220221a7 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 15 Oct 2022 16:56:59 +0800 Subject: [PATCH 16/31] Remove py3.6 and py3.7 --- .github/workflows/tests.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d764d009b..da15958b9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,8 +25,6 @@ jobs: - windows-latest dev: [false] python-version: - - "3.6" - - "3.7" - "3.8" - "3.9" - "3.10" From f2aec0bf0bb66aea9371475862b584ff9a4141a8 Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 08:55:19 +0800 Subject: [PATCH 17/31] Update name --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index da15958b9..09460fc65 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -name: unit tests +name: tests on: [pull_request] From 1391751a35e403feb2c4592916a78a53fb104884 Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 08:55:34 +0800 Subject: [PATCH 18/31] lint codes --- tests/test_documentation_build.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 0bdc229bb..3c74a4525 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -2,8 +2,6 @@ import pytest -import pytest - # If `mkdocs` wasn't installed in environment, just skip. # Can't use `pytest.importorskip("mkdocs")`, 'mkdocs' is also From 30cc453f513378661e4bff13437a9dd96764b83e Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 08:57:34 +0800 Subject: [PATCH 19/31] Add `lazy_loader` into env --- ci/envs/latest.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/envs/latest.yaml b/ci/envs/latest.yaml index b5002b78e..51c2cd970 100644 --- a/ci/envs/latest.yaml +++ b/ci/envs/latest.yaml @@ -6,6 +6,7 @@ dependencies: - pandas - pandas-flavor - multipledispatch + - lazy_loader - scipy # math, functions # optional From 609465b2541d78cd9ce90f9b9101796dfabd2770 Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 08:58:24 +0800 Subject: [PATCH 20/31] reversed changes to `test_documentation_build.py` --- tests/test_documentation_build.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index 3c74a4525..a10d1b540 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -1,5 +1,7 @@ """Tests for documentation build.""" +import os + import pytest @@ -17,6 +19,8 @@ def test_docs_general_functions_present(): all of the functions are present in the docs. This is an awesome thing that we could use help with in the future. """ + # Build docs using mkdocs + os.system("mkdocs build --clean") # We want to check that the following keywords are all present. # I put in a subsample of general functions. From 8079eca20c6fa7c828368dcf10c8b418be94aec6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 30 Oct 2022 00:58:53 +0000 Subject: [PATCH 21/31] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/test_documentation_build.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_documentation_build.py b/tests/test_documentation_build.py index a10d1b540..353ad6b5d 100644 --- a/tests/test_documentation_build.py +++ b/tests/test_documentation_build.py @@ -1,6 +1,6 @@ """Tests for documentation build.""" -import os +import os import pytest @@ -19,7 +19,7 @@ def test_docs_general_functions_present(): all of the functions are present in the docs. This is an awesome thing that we could use help with in the future. """ - # Build docs using mkdocs + # Build docs using mkdocs os.system("mkdocs build --clean") # We want to check that the following keywords are all present. From f6bf739357c2a80f04a6fcca030d4ecc68a595ae Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 09:01:34 +0800 Subject: [PATCH 22/31] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b0f83927..c0eb52bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - [BUG] pandas 1.5.x `_MergeOperation` doesn't have `copy` keyword anymore. Issue #1174 @Zeroto521 - [TST] Compat with macos and window, to fix `FailedHealthCheck` Issue #1181 @Zeroto521 - [INF] Merge two docs CIs (`docs-preview.yml` and `docs.yml`) to one. And add `documentation` pytest mark. PR #1183 @Zeroto521 +- [INF] Set a series of complete testing envs. Issue #1127 @Zeroto521 ## [v0.23.1] - 2022-05-03 From 208706a7e5ea54f27d10a1cfaca6864cd9034e0b Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 09:34:42 +0800 Subject: [PATCH 23/31] fix `hypothesis.errors.FailedHealthCheck` --- tests/functions/test_case_when.py | 1 + tests/functions/test_encode_categorical.py | 1 + tests/functions/test_expand_grid.py | 1 + 3 files changed, 3 insertions(+) diff --git a/tests/functions/test_case_when.py b/tests/functions/test_case_when.py index 8971f4e31..704034067 100644 --- a/tests/functions/test_case_when.py +++ b/tests/functions/test_case_when.py @@ -201,6 +201,7 @@ def test_case_when_default_list_like(df): @given(df=categoricaldf_strategy()) +@settings(deadline=None) def test_case_when_default_index(df): """ Test case_when for scenarios where `default` is an index. diff --git a/tests/functions/test_encode_categorical.py b/tests/functions/test_encode_categorical.py index fd4d6eeb7..fb77872c4 100644 --- a/tests/functions/test_encode_categorical.py +++ b/tests/functions/test_encode_categorical.py @@ -234,6 +234,7 @@ def test_empty_col_sort(df): @pytest.mark.functions @given(df=df_strategy()) +@settings(deadline=None) def test_empty_col_appearance(df): """ Raise ValueError if a string is provided, diff --git a/tests/functions/test_expand_grid.py b/tests/functions/test_expand_grid.py index 492958306..444c03801 100644 --- a/tests/functions/test_expand_grid.py +++ b/tests/functions/test_expand_grid.py @@ -13,6 +13,7 @@ @given(df=df_strategy()) +@settings(deadline=None) def test_others_not_dict(df): """Raise Error if `others` is not a dictionary.""" with pytest.raises(TypeError): From aad0f47edfa53a930377d5e14e3c86b916128163 Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 10:04:11 +0800 Subject: [PATCH 24/31] fix `hypothesis.errors.FailedHealthCheck` --- tests/functions/test_case_when.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functions/test_case_when.py b/tests/functions/test_case_when.py index 704034067..048b50a3f 100644 --- a/tests/functions/test_case_when.py +++ b/tests/functions/test_case_when.py @@ -166,6 +166,7 @@ def test_case_when_replacement_callable(df): @given(df=categoricaldf_strategy()) +@settings(deadline=None) def test_case_when_default_array(df): """ Test case_when for scenarios where `default` is array-like From 3a157eda71c8d9fc0e1404a8e980aa1cdc905611 Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 14:15:40 +0800 Subject: [PATCH 25/31] fix `hypothesis.errors.FailedHealthCheck` --- tests/functions/test_case_when.py | 1 + tests/functions/test_encode_categorical.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/functions/test_case_when.py b/tests/functions/test_case_when.py index 048b50a3f..aa7b2e516 100644 --- a/tests/functions/test_case_when.py +++ b/tests/functions/test_case_when.py @@ -184,6 +184,7 @@ def test_case_when_default_array(df): @given(df=categoricaldf_strategy()) +@settings(deadline=None) def test_case_when_default_list_like(df): """ Test case_when for scenarios where `default` is list-like, diff --git a/tests/functions/test_encode_categorical.py b/tests/functions/test_encode_categorical.py index fb77872c4..ab4805bae 100644 --- a/tests/functions/test_encode_categorical.py +++ b/tests/functions/test_encode_categorical.py @@ -258,6 +258,7 @@ def test_empty_col_appearance(df): @pytest.mark.functions @given(df=categoricaldf_strategy()) +@settings(deadline=None) def test_all_None(df): """ Test output where value is None. From 5ee95d66c6885b965cfb2da10ce38f3411390436 Mon Sep 17 00:00:00 2001 From: Zero Date: Sun, 30 Oct 2022 17:39:59 +0800 Subject: [PATCH 26/31] fix `hypothesis.errors.FailedHealthCheck` --- tests/functions/test_encode_categorical.py | 1 + tests/functions/test_expand_grid.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/functions/test_encode_categorical.py b/tests/functions/test_encode_categorical.py index ab4805bae..84ec60f95 100644 --- a/tests/functions/test_encode_categorical.py +++ b/tests/functions/test_encode_categorical.py @@ -271,6 +271,7 @@ def test_all_None(df): @pytest.mark.functions @given(df=categoricaldf_strategy()) +@settings(deadline=None) def test_all_cat_None_1(df): """ Test output where a string is provided. diff --git a/tests/functions/test_expand_grid.py b/tests/functions/test_expand_grid.py index 444c03801..f03a427f5 100644 --- a/tests/functions/test_expand_grid.py +++ b/tests/functions/test_expand_grid.py @@ -33,6 +33,7 @@ def test_others_empty(): @given(df=df_strategy()) +@settings(deadline=None) def test_df_key(df): """Raise error if df exists and df_key is not supplied.""" with pytest.raises(KeyError): From bec72932edd460a29511975f593a901d56bf68a4 Mon Sep 17 00:00:00 2001 From: Zero Date: Thu, 3 Nov 2022 09:24:16 +0800 Subject: [PATCH 27/31] fix `hypothesis.errors.FailedHealthCheck` --- tests/math/test_ecdf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/math/test_ecdf.py b/tests/math/test_ecdf.py index 03d71d159..58d3b3ea5 100644 --- a/tests/math/test_ecdf.py +++ b/tests/math/test_ecdf.py @@ -1,10 +1,12 @@ import numpy as np import pytest from hypothesis import given +from hypothesis import settings from hypothesis.extra.pandas import series @given(s=series(dtype=np.number)) +@settings(deadline=None) def test_ecdf(s): """A simple execution test.""" if s.isna().sum() > 0: From d13fb8d8fdf4f92285ea24b11ae6d73b2591dfc9 Mon Sep 17 00:00:00 2001 From: samukweku Date: Tue, 1 Nov 2022 22:17:02 +0000 Subject: [PATCH 28/31] add fix for GH#1184 --- tests/timeseries/test_fill_missing_timestamps.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/timeseries/test_fill_missing_timestamps.py b/tests/timeseries/test_fill_missing_timestamps.py index f07186e2d..ad735e9b4 100644 --- a/tests/timeseries/test_fill_missing_timestamps.py +++ b/tests/timeseries/test_fill_missing_timestamps.py @@ -26,7 +26,16 @@ def test_fill_missing_timestamps(timeseries_dataframe): df1 = timeseries_dataframe.drop(timeseries_dataframe.index[random_number]) # Fill missing timestamps - result = fill_missing_timestamps(df1, frequency="1H") + # fix for GH#1184 is to use the start and end from + # timeseries_dataframe + # imagine that the last row of df1 is removed, or the first entry + # the length check in the next line will fail + result = fill_missing_timestamps( + df1, + frequency="1H", + first_time_stamp=timeseries_dataframe.index.min(), + last_time_stamp=timeseries_dataframe.index.max(), + ) # Testing if the missing timestamp has been filled assert len(result) == len(timeseries_dataframe) From ad217f2dfd18e0972b83bd64441fb331e92d0288 Mon Sep 17 00:00:00 2001 From: Zero Date: Tue, 8 Nov 2022 14:46:03 +0800 Subject: [PATCH 29/31] Fix `hypothesis.errors.Flaky` --- tests/functions/test_encode_categorical.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functions/test_encode_categorical.py b/tests/functions/test_encode_categorical.py index 84ec60f95..c8819eb77 100644 --- a/tests/functions/test_encode_categorical.py +++ b/tests/functions/test_encode_categorical.py @@ -26,6 +26,7 @@ def df_checks(): @pytest.mark.functions @given(df=categoricaldf_strategy()) +@settings(deadline=None) def test_encode_categorical(df): df = df.encode_categorical("names") assert df["names"].dtypes == "category" From 03f4f528adb55eadec39219ae2f191dd5a975148 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 26 Nov 2022 16:29:12 +0800 Subject: [PATCH 30/31] Add `pytest-doctestplus` --- ci/envs/latest.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/envs/latest.yaml b/ci/envs/latest.yaml index 51c2cd970..d58beab4b 100644 --- a/ci/envs/latest.yaml +++ b/ci/envs/latest.yaml @@ -27,6 +27,7 @@ dependencies: - pytest - pytest-cov - pytest-xdist + - pytest-doctestplus - hypothesis - pandas-vet - interrogate From a48292d246f0827004b9d8492aae381ebac40fc4 Mon Sep 17 00:00:00 2001 From: Zero Date: Sat, 26 Nov 2022 16:29:47 +0800 Subject: [PATCH 31/31] docstrings tests will happen on some specific conditions --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3106973d6..4b3c5f5ef 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -53,6 +53,7 @@ jobs: run: python -m pip install -e . - name: Run docstrings tests + if: ${{ contains(matrix.env, 'latest.yaml') && contains(matrix.os, 'ubuntu') }} run: pytest -v -r a -n auto --color=yes --durations=0 --cov=janitor --cov-append --cov-report term-missing --cov-report xml --doctest-only janitor - name: Run not turtle unit tests