-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: Replace unittest asserts with pytest asserts (#1289)
- Loading branch information
Showing
15 changed files
with
318 additions
and
386 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
# Copyright 2012 splinter authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style | ||
# license that can be found in the LICENSE file. | ||
import pytest | ||
|
||
from splinter.exceptions import ElementDoesNotExist | ||
|
||
|
||
class ElementDoestNotExistTest: | ||
def test_element_query_should_raises_when_element_first_doest_exists(self): | ||
with self.assertRaises(ElementDoesNotExist): | ||
with pytest.raises(ElementDoesNotExist): | ||
self.browser.find_by_css(".element-that-dont-exists").first | ||
|
||
def test_element_list_raises_when_element_last_does_not_exists(self): | ||
with self.assertRaises(ElementDoesNotExist): | ||
with pytest.raises(ElementDoesNotExist): | ||
self.browser.find_by_css(".element-that-dont-exists").last | ||
|
||
def test_element_list_raises_when_element_does_not_exists(self): | ||
with self.assertRaises(ElementDoesNotExist): | ||
with pytest.raises(ElementDoesNotExist): | ||
self.browser.find_by_css(".element-that-dont-exists")[2] | ||
|
||
def test_element_list_raises_with_unicode_query(self): | ||
with self.assertRaises(ElementDoesNotExist): | ||
with pytest.raises(ElementDoesNotExist): | ||
self.browser.find_by_css(".element[title=título]").last | ||
|
||
def test_element_list_contains_right_information_and_raises_right_exception(self): | ||
"element list contains right information about query and raises nice exception message" | ||
with self.assertRaises(ElementDoesNotExist) as cm: | ||
with pytest.raises(ElementDoesNotExist) as err: | ||
element_list = self.browser.find_by_css(".element-that-dont-exists") | ||
self.assertEqual("css", element_list.find_by) | ||
self.assertEqual(".element-that-dont-exists", element_list.query) | ||
assert "css" == element_list.find_by | ||
assert ".element-that-dont-exists" == element_list.query | ||
element_list.first | ||
|
||
expected_message = 'No elements were found with css ".element-that-dont-exists"' | ||
|
||
e = cm.exception | ||
self.assertEqual(expected_message, e.args[0]) | ||
assert expected_message == err.value.args[0] | ||
|
||
def test_element_list_raises_when_element_first_doesnt_exists_in_element_context( | ||
self, | ||
): | ||
"element list raises exception with right information in element context" | ||
with self.assertRaises(ElementDoesNotExist) as cm: | ||
with pytest.raises(ElementDoesNotExist) as err: | ||
element_list = self.browser.find_by_css("#inside").find_by_css( | ||
".inner-element-that-dont-exists", | ||
) | ||
self.assertEqual("css", element_list.find_by) | ||
self.assertEqual(".inner-element-that-dont-exists", element_list.query) | ||
assert "css" == element_list.find_by | ||
assert ".inner-element-that-dont-exists" == element_list.query | ||
element_list.first | ||
|
||
expected_message = 'No elements were found with css ".inner-element-that-dont-exists"' | ||
|
||
e = cm.exception | ||
self.assertEqual(expected_message, e.args[0]) | ||
assert expected_message == err.value.args[0] |
Oops, something went wrong.