Skip to content

Commit

Permalink
fix: Fix deprecation pytest warning in 3.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin committed Mar 23, 2020
1 parent ba4fd73 commit f15a86b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## v0.2.1 (2020-03-23)

#### Fixes

* Fix deprecation pytest warning in 3.4.

## v0.1.1 (2020-03-09)


## v0.1.0 (2020-03-09)

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pytest-alembic"
version = "0.2.0"
version = "0.2.1"
description = "A pytest plugin for verifying alembic migrations."
authors = [
"Dan Cardin <[email protected]>",
Expand Down
16 changes: 12 additions & 4 deletions src/pytest_alembic/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,29 @@ def collect_tests(session, config):
test = all_tests[test_name]

# XXX: "tests" should become an ini configurable option.
result.append(PytestAlembicItem(f"tests::pytest_alembic::{test.__name__}", session, test))
result.append(
PytestAlembicItem.from_parent(
session, name=f"tests::pytest_alembic::{test.__name__}", test_fn=test
)
)

return result


class PytestAlembicItem(pytest.Item):
obj = None

def __init__(self, name, parent, test_fn):
super().__init__(name, parent, nodeid=name)
@classmethod
def from_parent(cls, parent, *, name, test_fn):
if hasattr(super(), "from_parent"):
self = super().from_parent(name=name, parent=parent)
else:
self = cls(name=name, parent=parent)

self.test_fn = test_fn
self.funcargs = {}

self.add_marker("alembic")
return self

def runtest(self):
fm = self.session._fixturemanager
Expand Down

0 comments on commit f15a86b

Please sign in to comment.