Skip to content
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

Fix bug with DSLMixin #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions capybara/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ def _define_package_method(name):

def _define_session_method(name):
@wraps(getattr(Session, name))
def func(*args, **kwargs):
def class_func(self, *args, **kwargs):
return getattr(page, name)(*args, **kwargs)

setattr(DSLMixin, name, func)
setattr(_module, name, func)
@wraps(getattr(Session, name))
def module_func(*args, **kwargs):
return getattr(page, name)(*args, **kwargs)

setattr(DSLMixin, name, class_func)
setattr(_module, name, module_func)


for _method in PACKAGE_METHODS:
Expand Down
12 changes: 12 additions & 0 deletions tests/test_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,15 @@ def test_is_nestable(self):
class TestSessionName(DSLTestCase):
def test_defaults_to_default(self):
assert capybara.session_name == "default"


class TestUsingDSLMixin(DSLTestCase):
@pytest.fixture
def myclass(self):
from capybara.dsl import DSLMixin
class MyClass(DSLMixin):
pass
return MyClass()

def test_uses_current_session(self, myclass):
assert myclass.has_no_current_path("/")