Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
139 additions
and
74 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 |
---|---|---|
|
@@ -4,4 +4,4 @@ | |
build | ||
.tox | ||
dist | ||
.env | ||
.eggs |
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 +1,3 @@ | ||
__version__ = "1.3.4" | ||
import pkg_resources | ||
|
||
__version__ = pkg_resources.get_distribution('flux').version |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[metadata] | ||
name = flux | ||
classifiers = | ||
Programming Language :: Python :: 2.7 | ||
Programming Language :: Python :: 3.6 | ||
Programming Language :: Python :: 3.7 | ||
summary = Artificial time library | ||
description-file = | ||
README.md | ||
description-content-type = text/markdown | ||
license = BSD | ||
author = Rotem Yaari | ||
author_email = vmalloc@gmail.com | ||
url = https://github.com/getslash/flux | ||
|
||
|
||
[extras] | ||
testing = | ||
pyforge | ||
pytest | ||
gevent |
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,25 +1,8 @@ | ||
import os | ||
from setuptools import setup, find_packages | ||
#!/usr/bin/env python | ||
from setuptools import setup | ||
|
||
with open(os.path.join(os.path.dirname(__file__), "flux", "__version__.py")) as version_file: | ||
exec(version_file.read()) # pylint: disable=W0122 | ||
|
||
setup(name="flux", | ||
description="Artificial time library", | ||
license="BSD", | ||
author="Rotem Yaari", | ||
author_email="vmalloc@gmail.com", | ||
classifiers=[ | ||
"Programming Language :: Python :: 2.6", | ||
"Programming Language :: Python :: 2.7", | ||
"Programming Language :: Python :: 3.3", | ||
"Programming Language :: Python :: 3.4", | ||
"Programming Language :: Python :: 3.5", | ||
], | ||
|
||
version=__version__, # pylint: disable=E0602 | ||
packages=find_packages(exclude=["tests"]), | ||
install_requires=[], | ||
scripts=[], | ||
namespace_packages=[] | ||
) | ||
setup( | ||
setup_requires=['pbr>=3.0', 'setuptools>=17.1'], | ||
pbr=True, | ||
long_description_content_type='text/markdown; charset=UTF-8', | ||
) |
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,36 @@ | ||
import time | ||
from forge import Forge | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def forge(request): | ||
|
||
returned = Forge() | ||
|
||
@request.addfinalizer | ||
def cleanup(): # pylint: disable=unused-variable | ||
returned.verify() | ||
returned.restore_all_replacements() | ||
|
||
return returned | ||
|
||
|
||
@pytest.fixture | ||
def mocked_time_module(): | ||
|
||
class _Mocked(object): | ||
|
||
def __init__(self): | ||
self._time = time.time() | ||
|
||
def time(self): | ||
return self._time | ||
|
||
def __set_time__(self, value): | ||
self._time = value | ||
|
||
def __advance__(self, increment=30): | ||
self._time += increment | ||
|
||
return _Mocked() |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from flux import timeline | ||
import pytest | ||
|
||
def test_time_drift_default_factor(forge, mocked_time_module): | ||
forge.replace_with(timeline, "time", mocked_time_module) | ||
t = timeline.Timeline() | ||
assert t.time() == mocked_time_module.time() | ||
mocked_time_module.__advance__() | ||
assert t.time() == mocked_time_module.time() | ||
|
||
def test_time_drift_change_restore_default_factor(forge, mocked_time_module): | ||
forge.replace_with(timeline, "time", mocked_time_module) | ||
t = timeline.Timeline() | ||
assert t.time() == mocked_time_module.time() | ||
mocked_time_module.__advance__() | ||
t.set_time_factor(1.5) | ||
t.set_time_factor(1) | ||
mocked_time_module.__advance__() | ||
assert t.time() == mocked_time_module.time() |