2019-10-15 01:28:42 -05:00
|
|
|
#
|
|
|
|
# Copyright (C) 2019 FreeIPA Contributors see COPYING for license
|
|
|
|
#
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def ipa_testdir(testdir):
|
|
|
|
"""
|
|
|
|
Create conftest within testdir.
|
|
|
|
"""
|
|
|
|
testdir.makeconftest(
|
|
|
|
"""
|
|
|
|
pytest_plugins = ["ipatests.pytest_ipa.deprecated_frameworks"]
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
return testdir
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def xunit_testdir(ipa_testdir):
|
|
|
|
"""
|
|
|
|
Create xnit style test module within testdir.
|
|
|
|
"""
|
|
|
|
ipa_testdir.makepyfile("""
|
|
|
|
def setup_module():
|
|
|
|
pass
|
|
|
|
def teardown_module():
|
|
|
|
pass
|
|
|
|
def setup_function():
|
|
|
|
pass
|
|
|
|
def teardown_function():
|
|
|
|
pass
|
|
|
|
|
|
|
|
class TestClass:
|
|
|
|
@classmethod
|
|
|
|
def setup_class(cls):
|
|
|
|
pass
|
|
|
|
@classmethod
|
|
|
|
def teardown_class(cls):
|
|
|
|
pass
|
|
|
|
def setup_method(self):
|
|
|
|
pass
|
|
|
|
def teardown_method(self):
|
|
|
|
pass
|
|
|
|
def test_m(self):
|
|
|
|
pass
|
|
|
|
""")
|
|
|
|
return ipa_testdir
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
def unittest_testdir(ipa_testdir):
|
|
|
|
"""
|
|
|
|
Create unittest style test module within testdir.
|
|
|
|
"""
|
|
|
|
ipa_testdir.makepyfile("""
|
|
|
|
import unittest
|
|
|
|
def setUpModule():
|
|
|
|
pass
|
|
|
|
def tearDownModule():
|
|
|
|
pass
|
|
|
|
class TestClass(unittest.TestCase):
|
|
|
|
@classmethod
|
|
|
|
def setUp(self):
|
|
|
|
pass
|
|
|
|
def tearDown(self):
|
|
|
|
pass
|
|
|
|
@classmethod
|
|
|
|
def setUpClass(cls):
|
|
|
|
pass
|
|
|
|
@classmethod
|
|
|
|
def tearDownClass(cls):
|
|
|
|
pass
|
|
|
|
def test_m(self):
|
|
|
|
pass
|
|
|
|
""")
|
|
|
|
return ipa_testdir
|
|
|
|
|
|
|
|
|
|
|
|
def test_xunit(xunit_testdir):
|
|
|
|
result = xunit_testdir.runpytest()
|
|
|
|
result.assert_outcomes(passed=1)
|
|
|
|
result.stdout.fnmatch_lines([
|
2020-07-29 05:19:26 -05:00
|
|
|
"* PytestIPADeprecationWarning: xunit style is deprecated in favour of "
|
2019-10-15 01:28:42 -05:00
|
|
|
"fixtures style",
|
|
|
|
"* 8 warning*",
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
def test_unittest(unittest_testdir):
|
|
|
|
result = unittest_testdir.runpytest()
|
|
|
|
result.assert_outcomes(passed=1)
|
|
|
|
result.stdout.fnmatch_lines([
|
2020-07-29 05:19:26 -05:00
|
|
|
"* PytestIPADeprecationWarning: unittest is deprecated in favour of "
|
2019-10-15 01:28:42 -05:00
|
|
|
"fixtures style",
|
|
|
|
"* 1 warning*",
|
|
|
|
])
|