oxrlib/tests/__init__.py

26 lines
518 B
Python
Raw Normal View History

2017-05-12 11:40:27 +00:00
import datetime
import decimal
import io
2017-05-09 13:56:08 +00:00
import pathlib
2017-05-12 11:40:27 +00:00
import random
import pytest
2017-05-09 13:56:08 +00:00
from oxrlib import __main__ as oxrmain
decimal.setcontext(oxrmain.decimal_context())
2017-05-09 13:56:08 +00:00
TEST_DIR = pathlib.Path(__file__).parent
class StringIO(io.StringIO):
def close(self):
self.last_value = self.getvalue()
super().close()
2017-05-09 14:32:23 +00:00
def relpath(*parts):
return TEST_DIR / pathlib.Path(*parts)
2017-05-12 11:40:27 +00:00
@pytest.fixture
def any_date():
return datetime.date.today() - datetime.timedelta(days=730 - random.randint(0, 365))