Skip to content

Commit 168c39d

Browse files
Migrate to using pytest as test runner.
1 parent 57e5b9c commit 168c39d

File tree

110 files changed

+39494
-38934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+39494
-38934
lines changed

doc/src/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Common Changes
7575
#) Fixed bug when attempting to append an element to a
7676
:ref:`DbObject <dbobjecttype>` which is not actually a collection.
7777
#) API documentation is now generated from the source code.
78+
#) The test suite now uses `pytest <https://docs.pytest.org/>`__.
7879
#) Internal change: `typing_extensions <https://pypi.org/project/
7980
typing-extensions/>`__ is now a dependency.
8081

pyproject.toml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,23 @@ Documentation = "http://python-oracledb.readthedocs.io"
5353
Issues = "https://github.com/oracle/python-oracledb/issues"
5454
Source = "https://github.com/oracle/python-oracledb"
5555

56+
[project.optional-dependencies]
57+
test = [
58+
"anyio",
59+
"numpy",
60+
"pandas",
61+
"pyarrow",
62+
"pytest",
63+
]
64+
oci_config = ["oci"]
65+
oci_auth = ["oci"]
66+
azure_config = [
67+
"azure-appconfiguration",
68+
"azure-identity",
69+
"azure-keyvault-secrets"
70+
]
71+
azure_auth = ["msal"]
72+
5673
[tool.setuptools]
5774
zip-safe = false
5875
packages = [
@@ -77,17 +94,8 @@ line-length = 79
7794
target-version = "py39"
7895
exclude = ["templates"]
7996

80-
[project.optional-dependencies]
81-
test = [
82-
"numpy",
83-
"pandas",
84-
"pyarrow",
85-
]
86-
oci_config = ["oci"]
87-
oci_auth = ["oci"]
88-
azure_config = [
89-
"azure-appconfiguration",
90-
"azure-identity",
91-
"azure-keyvault-secrets"
97+
[tool.pytest.ini_options]
98+
minversion = "8.3.0"
99+
testpaths = [
100+
"tests"
92101
]
93-
azure_auth = ["msal"]

tests/README.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
This directory contains the test suite for python-oracledb.
22

3-
1. The schemas and SQL objects that are referenced in the test suite can be
4-
created by running the Python script [create_schema.py][1]. The script
5-
requires administrative privileges and will prompt for these credentials as
6-
well as the names of the schemas that will be created, unless a number of
7-
environment variables are set as documented in the Python script
8-
[test_env.py][2]. Run the script using the following command:
3+
1. Install pytest and tox:
4+
5+
python -m pip install pytest tox --upgrade
96

10-
python create_schema.py
7+
2. Set the required database credential and related environment variables
8+
documented in [conftest.py][2].
119

12-
2. Install tox:
10+
3. The schemas and SQL objects that are referenced in the test suite can be
11+
created by running the Python script [create_schema.py][1]. The script
12+
requires administrative privileges to complete successfully:
1313

14-
python -m pip install tox --upgrade
14+
python -m pytest tests/create_schema.py
1515

16-
3. Run the test suite by issuing the following command in the top-level
16+
4. Run the test suite by issuing the following command in the top-level
1717
directory of your oracledb installation:
1818

1919
python -m tox
@@ -23,22 +23,26 @@ This directory contains the test suite for python-oracledb.
2323
Alternatively, you can use the currently installed build of oracledb and
2424
run the following command instead:
2525

26-
python -m unittest discover -v -s tests
26+
python -m pytest
2727

2828
You may also run each of the test scripts independently, as in:
2929

30-
python test_1000_module.py
30+
python -m pytest tests/test_1000_module.py
3131

32-
4. After running the test suite, the schemas can be dropped by running the
32+
The tests run in thin mode by default. If you wish to run the tests in
33+
thick mode, use the following command:
34+
35+
python -m pytest --use-thick-mode
36+
37+
5. After running the test suite, the schemas can be dropped by running the
3338
Python script [drop_schema.py][3]. The script requires administrative
34-
privileges and will prompt for these credentials as well as the names of
35-
the schemas that will be dropped, unless a number of environment variables
36-
are set as documented in the Python script [test_env.py][2]. Run the
39+
privileges to complete successfully. A set of environment variables should
40+
be set as documented in the Python script [conftest.py][2]. Run the
3741
script using the following command:
3842

39-
python drop_schema.py
43+
python -m pytest tests/drop_schema.py
4044

41-
5. Enable tests that require extra configuration
45+
6. Enable tests that require extra configuration
4246

4347
The following test(s) are automatically skipped if their required
4448
environment variable(s) and setup is not available.
@@ -64,7 +68,8 @@ This directory contains the test suite for python-oracledb.
6468
alter user <Schema Owner> grant connect through <External User>;
6569

6670

71+
6772
[1]: https://github.com/oracle/python-oracledb/blob/main/tests/create_schema.py
68-
[2]: https://github.com/oracle/python-oracledb/blob/main/tests/test_env.py
73+
[2]: https://github.com/oracle/python-oracledb/blob/main/tests/conftest.py
6974
[3]: https://github.com/oracle/python-oracledb/blob/main/tests/drop_schema.py
7075
[4]: https://python-oracledb.readthedocs.io/en/latest/user_guide/connection_handling.html#connecting-using-external-authentication

0 commit comments

Comments
 (0)