Skip to content

Commit

Permalink
Switch to pytest style
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Apr 15, 2024
1 parent 9e99812 commit ba03e0b
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,7 @@ section-order = [

[tool.ruff.lint.isort.sections]
repo = ['baseframe']

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = false
mark-parentheses = false
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ exclude = src/baseframe/static
enable-extensions = G
accept-encodings = utf-8
classmethod-decorators=classmethod, declared_attr
pytest-fixture-no-parentheses = false

[pycodestyle]
max-line-length = 88
Expand Down
2 changes: 0 additions & 2 deletions src/baseframe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
'errors',
'extensions',
'filters',
'filters',
'forms',
'forms',
'localize_timezone',
'localized_country_list',
Expand Down
6 changes: 3 additions & 3 deletions tests/baseframe_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from baseframe import baseframe


@pytest.fixture()
@pytest.fixture
def app():
"""App fixture."""
fixture_app = Flask(__name__)
Expand All @@ -18,13 +18,13 @@ def app():
return fixture_app


@pytest.fixture()
@pytest.fixture
def ctx(app):
with app.app_context() as context:
yield context


@pytest.fixture()
@pytest.fixture
def client(app):
"""App client fixture."""
with app.test_client() as test_client:
Expand Down
4 changes: 2 additions & 2 deletions tests/baseframe_tests/forms/fields_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class DateTimeForm(forms.Form):
# --- Tests ----------------------------------------------------------------------------


@pytest.fixture()
@pytest.fixture
def enum_form(ctx):
"""Enum form fixture."""
return EnumForm(meta={'csrf': False})
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_enum_render(enum_form) -> None:
)


@pytest.fixture()
@pytest.fixture
def json_form(ctx):
"""JSON form fixture."""
return JsonForm(meta={'csrf': False})
Expand Down
2 changes: 1 addition & 1 deletion tests/baseframe_tests/forms/form_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class FieldRenderForm(forms.Form):
string_field = forms.StringField("String")


@pytest.fixture()
@pytest.fixture
def user() -> SimpleUser:
return SimpleUser( # nosec
fullname="Test user", company="Test company", password="test"
Expand Down
6 changes: 3 additions & 3 deletions tests/baseframe_tests/forms/sqlalchemy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DocumentForm(forms.Form):
content = forms.TextAreaField("Content")


@pytest.fixture()
@pytest.fixture
def database(app):
"""Database structure."""
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite://'
Expand All @@ -52,7 +52,7 @@ def database(app):
db.drop_all()


@pytest.fixture()
@pytest.fixture
def db_session(database):
"""Database session fixture."""
savepoint = database.session.begin_nested()
Expand All @@ -61,7 +61,7 @@ def db_session(database):
database.session.rollback()


@pytest.fixture()
@pytest.fixture
def form(ctx):
return DocumentForm(model=Document, meta={'csrf': False})

Expand Down
2 changes: 1 addition & 1 deletion tests/baseframe_tests/forms/validators_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class PublicEmailDomainFormTest(forms.Form):
)


@pytest.fixture()
@pytest.fixture
def tforms(ctx):
urllib3.disable_warnings()
yield SimpleNamespace(
Expand Down
8 changes: 4 additions & 4 deletions tests/baseframe_tests/statsd_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
from baseframe.statsd import Statsd


@pytest.fixture()
@pytest.fixture
def app():
"""Redefine app without Baseframe for statsd tests."""
return Flask(__name__)


@pytest.fixture()
@pytest.fixture
def statsd(app):
s = Statsd()
s.init_app(app)
return s


@pytest.fixture()
@pytest.fixture
def view(app):
@app.route('/')
def index():
Expand All @@ -39,7 +39,7 @@ def index():
return index


@pytest.fixture()
@pytest.fixture
def form(app):
Babel(app) # Needed for form validator message translations

Expand Down
2 changes: 1 addition & 1 deletion tests/baseframe_tests/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# --- Fixtures -------------------------------------------------------------------------


@pytest.fixture()
@pytest.fixture
def testview(app):
"""Add a view to the app for testing."""

Expand Down

0 comments on commit ba03e0b

Please sign in to comment.