Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
876ecc8
Update pyproject.toml
surister Oct 14, 2025
3651e56
Add deps and metadata
surister Oct 14, 2025
45d8140
Add proper error formating to `BlobException`
surister Oct 14, 2025
15d53ec
Migrate test_cursor to pytest format.
surister Oct 14, 2025
c8dfa3a
Migrate several http tests
surister Oct 21, 2025
d854bbf
Rename `REQUEST` to `REQUEST_PATH` and move it to conftest.py with `f…
surister Oct 23, 2025
6c0c8b6
Migrate more tests
surister Oct 23, 2025
aa7794f
fix typo
surister Oct 23, 2025
8f46388
Clean imports
surister Oct 23, 2025
3bc6cff
Add specific tests for serialization
surister Oct 23, 2025
8cc192d
Add `temp_env` util function to temporarily set env variables with a …
surister Oct 23, 2025
4a2fbf8
Migrate client ca tests
surister Oct 23, 2025
b8a79fc
Migrate more tests
surister Oct 23, 2025
bf2903a
Migrate test_connection
surister Oct 23, 2025
6db454d
refactor fail_sometimes
surister Oct 24, 2025
010fcfa
Remove temp_env util function
surister Oct 24, 2025
08e9401
Migrate test_http and fix some test_cursor
surister Oct 24, 2025
1548b03
Fix linting
surister Oct 24, 2025
1cc2986
Fix CI
surister Oct 24, 2025
39ad8c9
Fix CI
surister Oct 24, 2025
0516259
Fix tests
surister Oct 24, 2025
65255bc
Renew default __repr__ implementation
surister Oct 27, 2025
10bfaec
Add more tests
surister Oct 27, 2025
7427104
Add more tests for cursors
surister Nov 11, 2025
3d723fd
format code
surister Nov 17, 2025
a451dcf
remove setup package instruction
surister Nov 17, 2025
2d81df8
update docs && remove zope references
surister Nov 17, 2025
2105ba8
remove uv.lock
surister Nov 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,32 @@ jobs:
- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
cache-dependency-glob: |
setup.py
cache-suffix: ${{ matrix.python-version }}
enable-cache: true
version: "latest"

- name: Setup env
run: uv sync
- name: Invoke tests
run: |

# Propagate build matrix information.
./devtools/setup_ci.sh

# Bootstrap environment.
source bootstrap.sh


# Run linter.
uv run ruff check .

# Run type testing
uv run mypy

# Report about the test matrix slot.
echo "Invoking tests with CrateDB ${CRATEDB_VERSION}"

# Run linter.
poe lint
uv run coverage run -m pytest

# Run tests.
coverage run bin/test -vvv

# Set the stage for uploading the coverage report.
coverage xml
uv run coverage xml

# https://github.com/codecov/codecov-action
- name: Upload coverage results to Codecov
Expand Down
36 changes: 14 additions & 22 deletions DEVELOP.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,41 @@ Running tests
=============

All tests will be invoked using the Python interpreter that was used when
creating the Python virtualenv. The test runner is `zope.testrunner`_.
creating the Python virtualenv. The test runner is `pytest`.

Some examples are outlined below. In order to learn about more details,
see, for example, `useful command-line options for zope-testrunner`_.

Run all tests::

poe test
uv run pytest

Run specific tests::

# Select modules.
bin/test -t test_cursor
bin/test -t client
bin/test -t testing
uv run pytest -k test_cursor.py
uv run pytest -k client

# Select doctests.
bin/test -t http.rst
uv run pytest --doctest-glob="*.rst"
uv run pytest --doctest-glob="connect.rst"

Ignore specific test directories::

bin/test --ignore_dir=testing
uv run pytest -k 'not testing'

The ``LayerTest`` test cases have quite some overhead. Omitting them will save
a few cycles (~70 seconds runtime)::

bin/test -t '!LayerTest'
uv run pytest -k 'not testing'

Invoke all tests without integration tests (~10 seconds runtime)::

bin/test --layer '!crate.testing.layer.crate' --test '!LayerTest'
uv run pytest -k 'not testing'

Yet ~60 test cases, but only ~1 second runtime::

bin/test --layer '!crate.testing.layer.crate' --test '!LayerTest' \
-t '!test_client_threaded' -t '!test_no_retry_on_read_timeout' \
-t '!test_wait_for_http' -t '!test_table_clustered_by'
uv run pytest -k 'not testing and not test_wait_for_http and not test_client_multithreaded and not test_keep_alive and not test_no_retry_on_read_timeout'

To inspect the whole list of test cases, run::

bin/test --list-tests
uv run pytest --collect-only

The CI setup on GitHub Actions (GHA) provides a full test matrix covering
relevant Python versions. You can invoke the software tests against a specific
Expand All @@ -84,15 +78,15 @@ Formatting and linting code
To use Ruff for code formatting, according to the standards configured in
``pyproject.toml``, use::

poe format
uv run ruff format

To lint the code base using Ruff and mypy, use::

poe lint
uv run ruff check && uv run mypy

Linting and software testing, all together now::

poe check
uv run pytest && uv run ruff check && uv run mypy


Renew certificates
Expand Down Expand Up @@ -169,8 +163,6 @@ nothing special you need to do to get the live docs to update.
.. _Sphinx: http://sphinx-doc.org/
.. _tests/assets/pki/*.pem: https://github.com/crate/crate-python/tree/main/tests/assets/pki
.. _twine: https://pypi.python.org/pypi/twine
.. _useful command-line options for zope-testrunner: https://pypi.org/project/zope.testrunner/#some-useful-command-line-options-to-get-you-started
.. _uv: https://docs.astral.sh/uv/
.. _UV_PYTHON: https://docs.astral.sh/uv/configuration/environment/#uv_python
.. _versions hosted on ReadTheDocs: https://readthedocs.org/projects/crate-python/versions/
.. _zope.testrunner: https://pypi.org/project/zope.testrunner/
17 changes: 0 additions & 17 deletions bin/test

This file was deleted.

1 change: 0 additions & 1 deletion bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ function main() {
ensure_virtualenv
activate_virtualenv
before_setup
setup_package
run_buildout
deactivate_uv
finalize
Expand Down
134 changes: 94 additions & 40 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,55 @@
[build-system]
requires = ["hatchling >= 1.26"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
packages = ["src/crate"]

[tool.hatch.version]
path = "src/crate/client/__init__.py"

[project]
name = "crate-python"
dynamic = ["version"]
description = "CrateDB Python Client"
authors = [{ name = "Crate.io", email = "office@crate.io" }]
requires-python = ">=3.10"
readme = "README.rst"
license = { file = "LICENSE"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Database",
]
dependencies = [
"orjson>=3.11.3",
"urllib3>=2.5.0",
]

[dependency-groups]
dev = [
"certifi>=2025.10.5",
"coverage>=7.11.0",
"mypy>=1.18.2",
"pytest>=8.4.2",
"pytz>=2025.2",
"ruff>=0.14.2",
"setuptools>=80.9.0",
"stopit>=1.1.2",
"verlib2>=0.3.1",
]


[tool.mypy]
mypy_path = "src"
packages = [
Expand All @@ -18,65 +70,67 @@ non_interactive = true
line-length = 80

extend-exclude = [
"/example_*",
"/example_*",
]

lint.select = [
# Builtins
"A",
# Bugbear
"B",
# comprehensions
"C4",
# Pycodestyle
"E",
# eradicate
"ERA",
# Pyflakes
"F",
# isort
"I",
# pandas-vet
"PD",
# return
"RET",
# Bandit
"S",
# print
"T20",
"W",
# flake8-2020
"YTT",
# Builtins
"A",
# Bugbear
"B",
# comprehensions
"C4",
# Pycodestyle
"E",
# eradicate
"ERA",
# Pyflakes
"F",
# isort
"I",
# pandas-vet
"PD",
# return
"RET",
# Bandit
"S",
# print
"T20",
"W",
# flake8-2020
"YTT",
]

lint.extend-ignore = [
# Unnecessary variable assignment before `return` statement
"RET504",
# Unnecessary `elif` after `return` statement
"RET505",
# Unnecessary variable assignment before `return` statement
"RET504",
# Unnecessary `elif` after `return` statement
"RET505",
]

lint.per-file-ignores."example_*" = [
"ERA001", # Found commented-out code
"T201", # Allow `print`
"ERA001", # Found commented-out code
"T201", # Allow `print`
]
lint.per-file-ignores."devtools/*" = [
"T201", # Allow `print`
"T201", # Allow `print`
]
lint.per-file-ignores."examples/*" = [
"ERA001", # Found commented-out code
"T201", # Allow `print`
"ERA001", # Found commented-out code
"T201", # Allow `print`
]
lint.per-file-ignores."tests/*" = [
"S106", # Possible hardcoded password assigned to argument: "password"
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
"S101", # Asserts.
"S105", # Possible hardcoded password assigned to: "password"
"S106", # Possible hardcoded password assigned to argument: "password"
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
]
lint.per-file-ignores."src/crate/client/{connection.py,http.py}" = [
"A004", # Import `ConnectionError` is shadowing a Python builtin
"A005", # Import `ConnectionError` is shadowing a Python builtin
"A004", # Import `ConnectionError` is shadowing a Python builtin
"A005", # Import `ConnectionError` is shadowing a Python builtin
]
lint.per-file-ignores."tests/client/test_http.py" = [
"A004", # Import `ConnectionError` is shadowing a Python builtin
"A004", # Import `ConnectionError` is shadowing a Python builtin
]


Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
setuptools<80.3
urllib3<2.4
zc.buildout==3.3
zope.interface==6.4.post2
zc.buildout==3.3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need the buildout?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For test_layer to be setup, ideally in future improvements we can drop it :)

Loading
Loading