summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2021-04-19 11:30:56 -0500
committerJordan Cook <jordan.cook@pioneer.com>2021-04-19 12:51:25 -0500
commitdd7ef7197a44688ed06356199f993161891363b2 (patch)
tree6f1a457a801e75ef4c34e09758afdc2e4868b10a
parent1fcbe2b30e4fdd96c345b5ea488ae51d3f542273 (diff)
downloadrequests-cache-dd7ef7197a44688ed06356199f993161891363b2.tar.gz
Use pytest-order to order tests; remove ipdb recommendation
-rw-r--r--.github/workflows/build.yml7
-rw-r--r--CONTRIBUTING.md10
-rwxr-xr-xruntests.sh7
-rw-r--r--setup.py1
-rw-r--r--tests/conftest.py3
-rw-r--r--tests/integration/test_dynamodb.py3
6 files changed, 9 insertions, 22 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 049ee38..4ad4fd3 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -55,9 +55,7 @@ jobs:
# Run unit tests first (and with multiprocessing) to fail quickly if there are issues
run: |
pytest tests/unit --numprocesses=auto ${{ env.COVERAGE_ARGS }}
- pytest -k 'not dynamodb' tests/integration ${{ env.COVERAGE_ARGS }} --cov-append
- # Run DynamoDB tests last, since that container takes the longest to initialize
- pytest tests/integration/test_dynamodb.py ${{ env.COVERAGE_ARGS }} --cov-append
+ pytest tests/integration --cov-append ${{ env.COVERAGE_ARGS }}
- name: Send code coverage report to Coveralls
if: ${{ matrix.python-version == env.LATEST_PY_VERSION }}
env:
@@ -69,8 +67,7 @@ jobs:
if: ${{ matrix.python-version != env.LATEST_PY_VERSION }}
run: |
pytest --numprocesses=auto tests/unit
- pytest -k 'not dynamodb' tests/integration
- pytest tests/integration/test_dynamodb.py
+ pytest tests/integration
# Run code analysis checks
analyze:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 14d71c8..6011389 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -83,16 +83,6 @@ pytest tests/integration/test_cache.py
For backend databases, you can install and run them on the host instead of in a container, as long
as they are running on the default port.
-## Debugging
-When you run into issues while working on new features and/or tests, it will make your life much easier
-to use a debugger instead of `print` statements. Most IDEs have a built-in debugger, but if
-you prefer the command line, [ipdb](https://github.com/gotcha/ipdb) is a good option. To install:
-```bash
-pip install ipython ipdb
-```
-
-The `runtests.sh` script will use ipdb by default, if it's installed.
-
## Documentation
[Sphinx](http://www.sphinx-doc.org/en/master/) is used to generate documentation.
diff --git a/runtests.sh b/runtests.sh
index ed45d57..6d6d31e 100755
--- a/runtests.sh
+++ b/runtests.sh
@@ -1,10 +1,7 @@
#!/usr/bin/env bash
# Test runner script with useful pytest options
-export PYTHONBREAKPOINT='ipdb.set_trace'
COVERAGE_ARGS='--cov --cov-report=term --cov-report=html'
# Run unit tests first (and with multiprocessing) to fail quickly if there are issues
-pytest -s tests/unit --numprocesses=auto $COVERAGE_ARGS
-pytest -s -k 'not dynamodb' tests/integration --cov-append $COVERAGE_ARGS
-# Run DynamoDB tests last, since that container takes the longest to initialize
-pytest -s tests/integration/test_dynamodb.py --cov-append $COVERAGE_ARGS
+pytest tests/unit --numprocesses=auto $COVERAGE_ARGS
+pytest tests/integration --cov-append $COVERAGE_ARGS
diff --git a/setup.py b/setup.py
index f942608..4d7a464 100644
--- a/setup.py
+++ b/setup.py
@@ -29,6 +29,7 @@ extras_require = {
'psutil',
'pytest>=5.0',
'pytest-cov>=2.11',
+ 'pytest-order~=0.11.0',
'pytest-xdist',
'radon',
'requests-mock>=1.8',
diff --git a/tests/conftest.py b/tests/conftest.py
index 17dfbc7..0b3167a 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -99,7 +99,6 @@ def tempfile_session() -> CachedSession:
suppress_warnings=True,
)
yield session
- requests_cache.uninstall_cache()
@pytest.fixture(scope='function')
@@ -171,7 +170,7 @@ def fail_if_no_connection(func) -> bool:
@wraps(func)
def wrapper(*args, **kwargs):
try:
- timeout(0.5)(func)(*args, **kwargs)
+ timeout(1.0)(func)(*args, **kwargs)
except Exception as e:
logger.error(e)
pytest.fail('Could not connect to backend')
diff --git a/tests/integration/test_dynamodb.py b/tests/integration/test_dynamodb.py
index 2f4e7fb..a79118b 100644
--- a/tests/integration/test_dynamodb.py
+++ b/tests/integration/test_dynamodb.py
@@ -5,6 +5,9 @@ from requests_cache.backends import DynamoDbDict
from tests.conftest import fail_if_no_connection
from tests.integration.test_backends import BaseStorageTestCase
+# Run this test module last, since the DynamoDB container takes the longest to initialize
+pytestmark = pytest.mark.order(-1)
+
boto_options = {
'endpoint_url': 'http://localhost:8000',
'region_name': 'us-east-1',