Skip to content

Conversation

lfdebrux
Copy link

@lfdebrux lfdebrux commented Oct 4, 2019

Creating a class that inherits from DSLMixin should allow it to use DSL methods, however instead I get a KeyError

Steps to reproduce bug

  1. Create a class that inherits from DSLMixin
  2. Instantiate the class
  3. Call a DSL method
>>> from capybara.dsl import DSLMixin

>>> class MyClass(DSLMixin):
...     pass
>>> mypage = MyClass()
>>> mypage.assert_selector('link', 'Help')

Expected behaviour

The DSL method returns as if calling capybara.dsl.<method>

>>> mypage.assert_selector('link', 'Help')
True

Actual behaviour

A KeyError is raised

>>> mypage.assert_selector('link', 'Help')
*** KeyError: <MyClass object at 0x7f16a350d780>

Suggested fix

DSLMixin should result in methods being attached to the class, rather than functions, so that the DSL methods can be used from instances of classes that inherit from DSLMixin.

I've attached a fix below that includes tests showing the behaviour I would expect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant