2017-05-12 11:40:27 +00:00
|
|
|
import datetime
|
2017-12-31 15:04:37 +00:00
|
|
|
import decimal
|
2017-05-12 17:48:21 +00:00
|
|
|
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
|
|
|
|
2017-12-31 15:04:37 +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
|
|
|
|
|
2017-05-12 17:48:21 +00:00
|
|
|
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))
|