-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding equal and making sure false and true are correct (#28)
* waiting for a real True * waiting for a real False * refactored out to_be_equal
- Loading branch information
Showing
8 changed files
with
149 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: "[Issue[" | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**TraceBacks** | ||
If applicable, add TraceBacks to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: "[feature-request]" | ||
labels: enhancement | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
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,5 +1,5 @@ | ||
black==19.3b0 | ||
docutils==0.15.2 | ||
pytest==5.0.1 | ||
pytest==5.1.1 | ||
twine==1.13.0 | ||
mock==3.0.5 |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import unittest | ||
|
||
from mock import patch, MagicMock | ||
|
||
import wait_for_it_to | ||
|
||
|
||
class TestWaitForItToBeEqual(unittest.TestCase): | ||
def test_wait_for_it_to_be_equal_immediately_returns_when_func_evals_to_the_same_String(self): | ||
foo = MagicMock() | ||
foo.return_value = "some_value" | ||
with patch("wait_for_it_to.time.sleep") as mocked_sleep: | ||
wait_for_it_to.be_equal(foo, "some_value") | ||
mocked_sleep.assert_not_called() | ||
|
||
def test_to_be_equal_sleeps_once_when_the_func_returns_only_after_the_second_try(self): | ||
foo = MagicMock() | ||
foo.side_effect = [0, 1] | ||
with patch("wait_for_it_to.time.sleep") as mocked_sleep: | ||
wait_for_it_to.be_equal(foo, 1) | ||
mocked_sleep.assert_called_with(0.01) | ||
|
||
def test_to_be_equal_calls_the_passed_function_object(self): | ||
foo = MagicMock() | ||
foo.return_value = True | ||
with patch("wait_for_it_to.time.sleep") as mocked_sleep: | ||
wait_for_it_to.be_equal(foo, True) | ||
foo.assert_called_once() | ||
|
||
def test_to_be_equal_raises_timeout_error_when_timeout_has_passed(self): | ||
foo = MagicMock() | ||
foo.return_value = False | ||
with patch("wait_for_it_to.time.sleep") as mocked_sleep: | ||
with patch("wait_for_it_to.time.time") as mocked_time: | ||
mocked_time.side_effect = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | ||
self.assertRaises(TimeoutError, wait_for_it_to.be_equal, foo, True) | ||
|
||
def test_i_can_set_a_custom_timeout_for_to_be_equal(self): | ||
foo = MagicMock() | ||
foo.return_value = "False" | ||
with patch("wait_for_it_to.time.sleep") as mocked_sleep: | ||
with patch("wait_for_it_to.time.time") as mocked_time: | ||
mocked_time.side_effect = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | ||
self.assertRaises(TimeoutError, wait_for_it_to.be_equal, foo, "True", 5) | ||
self.assertEqual(5, mocked_sleep.call_count) | ||
|
||
def test_default_timeout_for_to_be_equal_is_10_seconds(self): | ||
foo = MagicMock() | ||
foo.return_value = False | ||
with patch("wait_for_it_to.time.sleep") as mocked_sleep: | ||
with patch("wait_for_it_to.time.time") as mocked_time: | ||
mocked_time.side_effect = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] | ||
self.assertRaises(TimeoutError, wait_for_it_to.be_equal, foo, True) | ||
self.assertEqual(10, mocked_sleep.call_count) |
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,2 +1,2 @@ | ||
__version_info__ = (0, 0, 9) | ||
__version_info__ = (0, 0, 10) | ||
__version__ = ".".join(map(str, __version_info__)) |