-
Notifications
You must be signed in to change notification settings - Fork 979
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with BaseCase
and pytest-steps
?
#772
Comments
Hi @smarie , I'm familiar with this situation. It's explained by pytest-dev/pytest#3095 and pytest-dev/pytest#2535 (The origin of this issue comes from inheriting unittest.TestCase, which SeleniumBase's BaseCase does). There are a few different solutions to this. One is explained by the links above, which point to using from seleniumbase import BaseCase
from parameterized import parameterized
class GoogleTestClass(BaseCase):
@parameterized.expand([
["pypi", "pypi.org"],
["wikipedia", "wikipedia.org"],
["seleniumbase", "seleniumbase/SeleniumBase"],
])
def test_parameterized_google_search(self, search_term, expected_text):
self.open('https://google.com/ncr')
self.type('input[title="Search"]', search_term + '\n')
self.assert_element('#result-stats')
self.assert_text(expected_text, '#search') For the same reason that The second solution is a workaround that involves using SeleniumBase as a pytest fixture. That already exists: import pytest
@pytest.mark.parametrize('value', ["pytest", "selenium"])
def test_sb_fixture_with_no_class(sb, value):
sb.open("https://google.com/ncr")
sb.type('input[title="Search"]', value + '\n')
sb.assert_text(value, "div#center_col")
class Test_SB_Fixture():
@pytest.mark.parametrize('value', ["pytest", "selenium"])
def test_sb_fixture_inside_class(self, sb, value):
sb.open("https://google.com/ncr")
sb.type('input[title="Search"]', value + '\n')
sb.assert_text(value, "div#center_col") Using this technique, that modifies the original from pytest_steps import test_steps
class Test_MMMM():
@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) == 56
yield So to summarize, either |
This is great @mdmintz !! Thanks so much for the workaround. I'll ask the user to try it. Concerning the issue description though, pytest-steps does not create or use a parametrized autouse fixture, it just
So there is indeed a dependency to the Anyway if the workaround works, this is great ! Thanks again for answering so quickly |
Hi there, I am the author or
pytest-steps
and an user recently reported an issue withBaseCase
.smarie/python-pytest-steps#40
It is not clear to me if this use case should work or not, as I do not know
seleniumbase
. Would you be able to provide a few hints about the origin of the issue ? If there is something I can do onpytest-steps
to make it compliant withseleniumbase
I'll happily do it. Thanks!The text was updated successfully, but these errors were encountered: