Skip to content

Improving examples #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
21 changes: 19 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,20 @@ classifiers = [
]
dependencies = [
# Put the project's production dependencies here:

"allure-pytest==2.13.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Only production dependencies should go here (of which we have none).

Currently, Python has no standard way to define development dependencies. This concept is tool-specific.

This repo uses the requirements file (this is the best option when using raw pip IMO). So, we should leave the dev deps in the requirement file instead of putting them in pyproject.toml.

This discussion covers dev dependencies in great detail.

"allure-python-commons==2.13.5",
"attrs==25.1.0",
"exceptiongroup==1.2.2",
"flake8==7.1.2",
"flake8-builtins==2.5.0",
"iniconfig==2.0.0",
"mccabe==0.7.0",
"packaging==24.2",
"pluggy==1.5.0",
"pycodestyle==2.12.1",
"pyflakes==3.2.0",
"pytest==8.3.4",
"tomli==2.2.1",
]

[project.optional-dependencies]
Expand All @@ -26,4 +39,8 @@ dev = [
]

[tool.pytest.ini_options]
testpaths = ["test"]
testpaths = ["test"]

addopts = [
"--alluredir", "allure-results",
Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense. Let's remove these arguments from run scripts then.

]
10 changes: 4 additions & 6 deletions test/test_sum.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import allure
import pytest


def test_sum():
assert 1 + 2 == 3


def test_sum_loop():
data = [
[1, 2, 3],
Expand All @@ -15,22 +13,22 @@ def test_sum_loop():
for x, y, ttl in data:
assert x + y == ttl


data = [
[1, 2, 3],
[-1, 1, 0],
[0, 0, 0]
]

def prepare_test_data(param):
return data[param]

@pytest.mark.parametrize("x,y,ttl", data)
def test_sum_parameterized(x, y, ttl):
assert x + y == ttl


@pytest.fixture(params=data)
@pytest.fixture(params=[0, 1, 2])
def sum_arguments(request):
return request.param[0], request.param[1], request.param[2]
yield prepare_test_data(request.param)

def test_sum_simple(sum_arguments):
x, y, ttl = sum_arguments
Expand Down