Skip to content

Commit

Permalink
style: import specific jinja attrs
Browse files Browse the repository at this point in the history
This avoids a false positive for B701, PyCQA/bandit#711

Also ran black and added docstring
  • Loading branch information
shifqu committed Jul 22, 2021
1 parent bf93b67 commit 7fe09b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 5 additions & 4 deletions pytest_generator/generate_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
from types import MethodType, ModuleType
from typing import Any, Callable, Optional

import jinja2
from jinja2 import Environment, FileSystemLoader, select_autoescape

env = jinja2.Environment(
loader=jinja2.FileSystemLoader(Path(__file__).parent.parent / "templates"),
autoescape=jinja2.select_autoescape(),
env = Environment(
loader=FileSystemLoader(Path(__file__).parent.parent / "templates"),
autoescape=select_autoescape(),
)


def generate(root: Path):
"""Generate tests for all modules under `root`."""
if not root.is_absolute():
root = root.absolute()

Expand Down
4 changes: 1 addition & 3 deletions tests/pytest_generator/test_generate_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from pytest_generator import generate_tests

from pytest_generator import generate_tests


@pytest.mark.parametrize(("expected_output"), [("x")])
Expand All @@ -9,14 +9,12 @@ def test_generate_tests_generate(expected_output):
assert return_value == expected_output



@pytest.mark.parametrize(("expected_output"), [("x")])
def test_generate_tests__get_local_members(expected_output):
return_value = generate_tests._get_local_members()
assert return_value == expected_output



@pytest.mark.parametrize(("expected_output"), [("x")])
def test_generate_tests__collect_members_and_write_tests(expected_output):
return_value = generate_tests._collect_members_and_write_tests()
Expand Down
2 changes: 1 addition & 1 deletion tests/pytest_generator/test_main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from pytest_generator import main

from pytest_generator import main


@pytest.mark.parametrize(("expected_output"), [("x")])
Expand Down

0 comments on commit 7fe09b6

Please sign in to comment.