-
-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci/integration: use unified fixtures
- Loading branch information
Showing
7 changed files
with
107 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1 @@ | ||
import pytest | ||
|
||
from pyroute2 import NDB, IPRoute, netns | ||
from pyroute2.common import uifname | ||
|
||
|
||
@pytest.fixture | ||
def nsname(request, tmpdir): | ||
name = uifname() | ||
netns.create(name) | ||
yield name | ||
try: | ||
netns.remove(name) | ||
except: | ||
pass | ||
|
||
|
||
@pytest.fixture | ||
def link(request, tmpdir, nsname): | ||
name = uifname() | ||
with IPRoute(netns=nsname) as ipr: | ||
ipr.link('add', ifname=name, kind='dummy') | ||
(link,) = ipr.link('get', ifname=name) | ||
link.netns = nsname | ||
yield link | ||
try: | ||
ipr.link('del', index=link['index']) | ||
except: | ||
pass | ||
|
||
|
||
@pytest.fixture | ||
def ifname(link): | ||
return link.get('ifname') | ||
|
||
|
||
@pytest.fixture | ||
def ipr(nsname): | ||
with IPRoute(netns=nsname) as ipr: | ||
yield ipr | ||
|
||
|
||
@pytest.fixture | ||
def ndb(nsname): | ||
with NDB(sources=[{'target': 'localhost', 'netns': nsname}]) as ndb: | ||
yield ndb | ||
pytest_plugins = ["pyroute2.fixtures.iproute", "pyroute2.fixtures.plan9"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters