Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zahra Rajabi
tweepy
Commits
97344add
Unverified
Commit
97344add
authored
Nov 04, 2016
by
Aaron Hill
Browse files
Don't sleep when replaying recorded data
parent
a7d21baf
Changes
2
Hide whitespace changes
Inline
Side-by-side
tests/config.py
View file @
97344add
...
...
@@ -33,7 +33,7 @@ class TweepyTestCase(unittest.TestCase):
self
.
auth
=
create_auth
()
self
.
api
=
API
(
self
.
auth
)
self
.
api
.
retry_count
=
2
self
.
api
.
retry_delay
=
5
self
.
api
.
retry_delay
=
0
if
use_replay
else
5
def
create_auth
():
...
...
tests/test_api.py
View file @
97344add
import
unittest
import
random
import
shutil
from
time
import
sleep
import
time
import
os
from
ast
import
literal_eval
...
...
@@ -440,7 +440,7 @@ class TweepyAPITests(TweepyTestCase):
class
TweepyCacheTests
(
unittest
.
TestCase
):
timeout
=
2.0
timeout
=
0.5
memcache_servers
=
[
'127.0.0.1:11211'
]
# must be running for test to pass
def
_run_tests
(
self
,
do_cleanup
=
True
):
...
...
@@ -450,14 +450,14 @@ class TweepyCacheTests(unittest.TestCase):
'Stored value does not match retrieved value'
)
# test timeout
sleep
(
self
.
timeout
)
sleep
(
self
.
timeout
,
True
)
self
.
assertEqual
(
self
.
cache
.
get
(
'testkey'
),
None
,
'Cache entry should have expired'
)
# test cleanup
if
do_cleanup
:
self
.
cache
.
store
(
'testkey'
,
'testvalue'
)
sleep
(
self
.
timeout
)
sleep
(
self
.
timeout
,
True
)
self
.
cache
.
cleanup
()
self
.
assertEqual
(
self
.
cache
.
count
(),
0
,
'Cache cleanup failed'
)
...
...
@@ -484,6 +484,11 @@ class TweepyCacheTests(unittest.TestCase):
if
os
.
path
.
exists
(
'cache_test_dir'
):
shutil
.
rmtree
(
'cache_test_dir'
)
old_sleep
=
time
.
sleep
def
sleep
(
t
,
override
=
False
):
if
not
use_replay
or
override
:
old_sleep
(
t
)
if
__name__
==
'__main__'
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment