Skip to content

Commit

Permalink
Moving test_factory.py to pytest fixtures.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisfremen committed Mar 28, 2020
1 parent 7352ae4 commit a0dc8bd
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
from datetime import date, datetime

import dateparser
import pytest
from dateutil import tz

from arrow import factory
from arrow.parser import ParserError

from .utils import assert_datetime_equality

import pytest

@pytest.fixture(scope="class")
def factory_fixture(request):
request.cls.factory = factory.ArrowFactory()

class TestGet:
@classmethod
def setup_class(cls):
cls.factory = factory.ArrowFactory()

@pytest.mark.usefixtures("factory_fixture")
class TestGet:
def test_no_args(self):

assert_datetime_equality(
Expand Down Expand Up @@ -333,11 +335,8 @@ def test_locale_with_tzinfo(self):
assert res.tzinfo == tz.gettz("Asia/Tokyo")


@pytest.mark.usefixtures("factory_fixture")
class TestUtcNow:
@classmethod
def setup_class(cls):
cls.factory = factory.ArrowFactory()

def test_utcnow(self):

assert_datetime_equality(
Expand All @@ -346,11 +345,8 @@ def test_utcnow(self):
)


@pytest.mark.usefixtures("factory_fixture")
class TestNow:
@classmethod
def setup_class(cls):
cls.factory = factory.ArrowFactory()

def test_no_tz(self):

assert_datetime_equality(self.factory.now(), datetime.now(tz.tzlocal()))
Expand Down

0 comments on commit a0dc8bd

Please sign in to comment.