Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]

steps:
- uses: actions/checkout@v3
Expand All @@ -23,7 +23,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest pytest-cov pytest-xdist responses==0.21.0 ruff==0.11.8
python -m pip install pytest pytest-cov pytest-xdist responses==0.21.0 ruff==0.14.10
python -m pip install -e .
- name: Format check
run: |
Expand Down
10 changes: 5 additions & 5 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
pytest = "==8.4.0"
pytest-cov = "==6.2.1"
pytest = "==9.0.2"
pytest-cov = "==7.0.0"
responses = "==0.21.0"
ruff = "==0.11.8"
pytest-xdist = "==3.7.0"
ruff = "==0.14.10"
pytest-xdist = "==3.8.0"

[packages]
requests = "==2.32.4"
requests = "==2.32.5"
testrail-api = { editable = true, path = "." }

[requires]
Expand Down
27 changes: 25 additions & 2 deletions ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,26 @@ select = [
"FLY", # flynt
"PL", # Pylint
"RSE", # flake8-raise
"ERA", # eradicate (Закомменченый код)
"BLE", # flake8-blind-except
"FBT", # flake8-boolean-trap
"DTZ", # flake8-datetimez
"INT", # flake8-gettext
"TC", # flake8-type-checking
"W", # pycodestyle (warning)
"PLR", # Refactor
"PLW", # Warning
"TRY", # Warning
"ASYNC", # flake8-async
"T10", # flake8-debugger
"EM", # flake8-errmsg
"EXE", # flake8-executable
"LOG", # flake8-logging
"G", # flake8-logging-format
"SLF", # flake8-self
"SLOT", # flake8-slots
"TID", # flake8-tidy-imports
"PLE", # Pylint Error
]
ignore = [
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposesStandard pseudo-random generators are not suitable for cryptographic purposes
Expand All @@ -44,11 +64,14 @@ ignore = [
"ANN003", # Missing type annotation for `**kwargs`
"ANN002", # Missing type annotation for `*args`
"D107", # Missing docstring in `__init__`
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed`
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"EM101", # Exception must not use a string literal, assign to variable first
"EM102", # Exception must not use an f-string literal, assign to variable first
"TRY003", # Avoid specifying long messages outside the exception class
]

[lint.per-file-ignores]
"test_*.py" = ["S101", "D103", "ANN201", "D100", "S605", "S607", "ANN001", "PLR2004", "PT018", "ARG002", "D102", "ANN204", "A004", "PT012"]
"test_*.py" = ["S101", "D103", "ANN201", "D100", "S605", "S607", "ANN001", "PLR2004", "PT018", "ARG002", "D102", "ANN204", "A004", "PT012", "DTZ005", "PT030"]
"conftest.py" = ["ANN001", "PLR0913", "D101", "D100"]
"_category.py" = ["D401", "A002"]

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
13 changes: 7 additions & 6 deletions testrail_api/_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def user_email(self) -> str:
return self.__user_email

@staticmethod
def __get_url(url: str, warn_ignore: bool) -> str:
def __get_url(url: str, *, warn_ignore: bool) -> str:
"""Read URL."""
if not (_url := url or environ.get(Environ.URL)):
raise TestRailError(f"Url is not set. Use argument url or env {Environ.URL}")
Expand Down Expand Up @@ -205,7 +205,7 @@ def post(
json=json or {},
)

def request(self, method: METHODS, endpoint: str, raw: bool = False, **kwargs) -> Any:
def request(self, method: METHODS, endpoint: str, *, raw: bool = False, **kwargs) -> Any:
"""Send request method."""
url = f"{self.__base_url}{endpoint}"
if not endpoint.startswith("add_attachment"):
Expand All @@ -215,17 +215,17 @@ def request(self, method: METHODS, endpoint: str, raw: bool = False, **kwargs) -
self.__get_converter(kwargs.get("params", {}))
self.__post_converter(kwargs.get("json", {}))

for count in range(self.__exc_iterations): # noqa: RET503
for count in range(self.__exc_iterations):
try:
response = self.__session.request(method=str(method.value), url=url, timeout=self.__timeout, **kwargs)
except self.__retry_exceptions as exc:
if count < self.__exc_iterations - 1:
logger.warning("%s, retrying %s/%s", exc, count + 1, self.__exc_iterations)
continue
raise
except Exception as err:
logger.error("%s", err, exc_info=True)
raise err
except Exception:
logger.exception("Request error")
raise
if (
self._rate_limit
and response.status_code == RATE_LIMIT_STATUS_CODE
Expand All @@ -235,6 +235,7 @@ def request(self, method: METHODS, endpoint: str, raw: bool = False, **kwargs) -
continue
logger.debug("Response header: %s", response.headers)
return response if raw else self.__response_handler(response)
return None

@staticmethod
def _path(path: Union[Path, str]) -> Path:
Expand Down
6 changes: 0 additions & 6 deletions tests/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ def delete_cases(r, project_id=None, case_ids=None, suite_id=None, soft=0):
return 200, {}, ""


# def copy_cases_to_section(r):
# body = json.loads(r.body.decode())
# assert body['case_ids'] == '1,2,3'
# return 200, {}, ''


def test_get_case(api, mock, url):
mock.add_callback(
responses.GET,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CustomException(Exception):
class CustomExceptionRetry:
"""Exception retry."""

def __init__(self, exception=CustomException, fail=False) -> None:
def __init__(self, exception=CustomException, *, fail=False) -> None:
self.count = 0
self.exception = exception
self.fail = fail
Expand Down