Closed IvanHrytskiv closed 3 years ago
When I am try pytest test_my_1111.py --html=4444444444.html I have errors:
pytest test_my_1111.py --html=4444444444.html (Running with --headless on Linux. Use --headed or --gui to override.) ============================================================================================ test session starts ============================================================================================= platform linux -- Python 3.6.9, pytest-6.2.1, py-1.10.0, pluggy-0.13.1 rootdir: /opt/PycharmProject/SelenBase/SeleniumBase, configfile: pytest.ini plugins: html-profiling-1.0.0, html-reporter-0.2.3, xdist-2.2.0, forked-1.3.0, ordering-0.6, rerunfailures-9.1.1, steps-1.7.3, allure-pytest-2.8.29, metadata-1.11.0, cov-2.10.1, seleniumbase-1.51.4 collected 2 items
test_my_1111.py FF
================================================================================================== FAILURES ================================================================================================== _ MMMM.test_my12345
self =
def test_my_12345(self):
with allure.step('Моя перша алюра'):
assert True
with allure.step('Моя second алюра'):
assert False
E AssertionError: assert False
test_my_1111.py:32: AssertionError __ MMMM.test_suite ___
self = <unittest.case._Outcome object at 0x7f13e196ec18>, test_case =
@contextlib.contextmanager
def testPartExecutor(self, test_case, isTest=False):
old_success = self.success
self.success = True
try:
yield
/usr/lib/python3.6/unittest/case.py:59:
self =
def run(self, result=None):
orig_result = result
if result is None:
result = self.defaultTestResult()
startTestRun = getattr(result, 'startTestRun', None)
if startTestRun is not None:
startTestRun()
result.startTest(self)
testMethod = getattr(self, self._testMethodName)
if (getattr(self.__class__, "__unittest_skip__", False) or
getattr(testMethod, "__unittest_skip__", False)):
# If the class or method was skipped.
try:
skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
or getattr(testMethod, '__unittest_skip_why__', ''))
self._addSkip(result, self, skip_why)
finally:
result.stopTest(self)
return
expecting_failure_method = getattr(testMethod,
"__unittest_expecting_failure__", False)
expecting_failure_class = getattr(self,
"__unittest_expecting_failure__", False)
expecting_failure = expecting_failure_class or expecting_failure_method
outcome = _Outcome(result)
try:
self._outcome = outcome
with outcome.testPartExecutor(self):
self.setUp()
if outcome.success:
outcome.expecting_failure = expecting_failure
with outcome.testPartExecutor(self, isTest=True):
testMethod()
E TypeError: test_suite() missing 2 required positional arguments: '____stepname' and 'request'
/usr/lib/python3.6/unittest/case.py:605: TypeError ------------------------------------------------------ generated html file: file:///opt/PycharmProject/SelenBase/SeleniumBase/examples/4444444444.html ------------------------------------------------------- ----------------------------------------------------------------- LogPath: /opt/PycharmProject/SelenBase/SeleniumBase/examples/latest_logs/ ------------------------------------------------------------------ ========================================================================================== short test summary info =========================================================================================== FAILED test_my_1111.py::MMMM::test_my_12345 - AssertionError: assert False FAILED test_my_1111.py::MMMM::test_suite - TypeError: test_suite() missing 2 required positional arguments: '____stepname' and 'request' ============================================================================================= 2 failed in 3.74s ==============================================================================================
Hi @IvanHrytskiv , thanks for reaching out !
Does the bug appear when you run this outside of selenium, but still in a class ? I'm trying to figure out if this due to a conflict with the selenium framework, or to the fact that this is a test method inside a class (and not a module-level function)
What @test_steps
does is that it wraps your function with a test function that requires two new arguments ('___step_name' and 'request', as can be seen in the stack trace), and it decorates it with a @pytest.mark.parametrize
if I remember well, in order to change the values for '___step_name'. 'requests' is a fixture that pytest injects automatically when present in a test function signature. So both should be injected by pytest in the end.
Hi ! Does the bug appear when you run this outside of selenium, but still in a class ? = YES
пн, 4 січ. 2021 о 17:43 Sylvain Marié notifications@github.com пише:
Hi @IvanHrytskiv https://github.com/IvanHrytskiv , thanks for reaching out !
Does the bug appear when you run this outside of selenium, but still in a class ? I'm trying to figure out if this due to a conflict with the selenium framework, or to the fact that this is a test method inside a class (and not a module-level function)
What @test_steps does is that it wraps your function with a test function that requires two new arguments ('___step_name' and 'request', as can be seen in the stack trace). The first is a parameter injected with a generated @parametrize if I remember well, and the second is the traditional fixture from pytest. So both should be injected by pytest in the end.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/smarie/python-pytest-steps/issues/40#issuecomment-754049697, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXSBTJVP57PP5CABYGFCC3SYHO2RANCNFSM4VF2VMOQ .
I'm sorry but I cant' reproduce the error on my side. The following code works correctly:
from pytest_steps import test_steps
class TestClass:
@test_steps('step_a', 'step_b', 'step_c')
def test_suite(self):
# Step A
print("step a")
assert not False # replace with your logic
intermediate_a = 'hello'
yield
# Step B
print("step b")
assert not False # replace with your logic
yield
# Step C
print("step c")
new_text = intermediate_a + " ... augmented"
print(new_text)
assert len(new_text) == 19
yield
Do you confirm ?
TestClass(BaseCkass) - don't work for me(((
вт, 5 січ. 2021, 10:28 користувач Sylvain Marié notifications@github.com пише:
I'm sorry but I cant' reproduce the error on my side. The following code works correctly:
from pytest_steps import test_steps class TestClass: @test_steps('step_a', 'step_b', 'step_c') def test_suite(self):
Step A
print("step a") assert not False # replace with your logic intermediate_a = 'hello' yield # Step B print("step b") assert not False # replace with your logic yield # Step C print("step c") new_text = intermediate_a + " ... augmented" print(new_text) assert len(new_text) == 19 yield
Do you confirm ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/smarie/python-pytest-steps/issues/40#issuecomment-754487123, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXSBTLYWD6UUPDPCRUZDI3SYLEUHANCNFSM4VF2VMOQ .
So this is an issue with seleniumbase
apparently. I opened an issue there: https://github.com/seleniumbase/SeleniumBase/issues/772
Cool, thanks!
вт, 5 січ. 2021, 13:26 користувач Sylvain Marié notifications@github.com пише:
So this is an issue with seleniumbase apparently. I opened an issue there: seleniumbase/SeleniumBase#772 https://github.com/seleniumbase/SeleniumBase/issues/772
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/smarie/python-pytest-steps/issues/40#issuecomment-754578399, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXSBTLK3DHTZQTWHMVYICTSYLZPBANCNFSM4VF2VMOQ .
@IvanHrytskiv , @smarie See: https://github.com/seleniumbase/SeleniumBase/issues/772#issuecomment-754664651
It's an issue with pytest + unittest.TestCase compatibility, and there are 2 solutions (both mentioned in the link above). Either a small change needs to be made to pytest-steps
, or users need to use SeleniumBase's sb
fixture when creating tests with SeleniumBase that use parameter-passing fixtures that aren't set to autouse
.
So @IvanHrytskiv the following should work:
from pytest_steps import test_steps
class TestMMMM():
@test_steps('step_a', 'step_b', 'step_c')
def test_suite(self, sb):
# Step A
print("step a")
assert not False # replace with your logic
intermediate_a = 'hello'
yield
# Step B
print("step b")
assert not False # replace with your logic
yield
# Step C
print("step c")
new_text = intermediate_a + " ... augmented"
print(new_text)
assert len(new_text) == 19
yield
Note the added sb
parameter in the test function arguments, and the removed inheritance of BaseCase
Thanks !!!!)))) Great job ))))
The class line may need to be class Test_MMMM():
for pytest test discovery to pick it up during test collection. And if you use SeleniumBase methods inside, it would now start with sb.
instead of self.
. Example: sb.open(URL)
.
I updated the example, thanks @mdmintz ! @IvanHrytskiv I close this ticket since it seems to solve the issue on your side. If this is not the case feel free to reopen. Thanks again for contributing !
Cool, thanks! Fast and perfect job ! The Best Regards, Ivan.
вт, 5 січ. 2021, 23:34 користувач Sylvain Marié notifications@github.com пише:
Closed #40 https://github.com/smarie/python-pytest-steps/issues/40.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/smarie/python-pytest-steps/issues/40#event-4172089143, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXSBTL37H2J4UAUCZLATEDSYOAWTANCNFSM4VF2VMOQ .
H! I still have a question so as not to get into an unresolved situation again:
How can I use celery in seleniumbase and pytest_steps ?
And another question: How do you recommend from the front end from the web interface to run, for example, pytests with different parameters,
as well as to specify for celery a schedule for running specific tests?
Thanks !
The Best Regards, Ivan
ср, 6 січ. 2021 о 00:31 Sunsey sunsey01@gmail.com пише:
Cool, thanks! Fast and perfect job ! The Best Regards, Ivan.
вт, 5 січ. 2021, 23:34 користувач Sylvain Marié notifications@github.com пише:
Closed #40 https://github.com/smarie/python-pytest-steps/issues/40.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/smarie/python-pytest-steps/issues/40#event-4172089143, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABXSBTL37H2J4UAUCZLATEDSYOAWTANCNFSM4VF2VMOQ .
Hi @IvanHrytskiv , unfortunately I have no experience with celery nor selenium :(
from pytest_steps import test_steps from seleniumbase import BaseCase
class MMMM(BaseCase):