Esempio n. 1
0
def test_tz_path():
    here = os.path.realpath(os.path.dirname(__file__))
    filepath = os.path.realpath(
        os.path.join(here, '..', 'pytzdata', 'zoneinfo', 'Europe', 'Paris')
    )

    assert filepath == tz_path('Europe/Paris')
Esempio n. 2
0
    def read_for(self, timezone):  # type: (str) -> Timezone
        """
        Read the zoneinfo structure for a given timezone name.

        :param timezone: The timezone.
        """
        try:
            file_path = pytzdata.tz_path(timezone)
        except TimezoneNotFound:
            raise InvalidTimezone(timezone)

        return self.read(file_path)
Esempio n. 3
0
    def read_for(self, timezone):  # type: (str) -> Timezone
        """
        Read the zoneinfo structure for a given timezone name.

        :param timezone: The timezone.
        """
        try:
            file_path = pytzdata.tz_path(timezone)
        except TimezoneNotFound:
            raise InvalidTimezone(timezone)

        return self.read(file_path)
Esempio n. 4
0
def test_tz_path_empty_string():
    with pytest.raises(ValueError):
        tz_path('')
Esempio n. 5
0
def test_tz_path_invalid_name():
    with pytest.raises(ValueError):
        tz_path('Europe/../Paris')
Esempio n. 6
0
def test_tz_path_not_found():
    with pytest.raises(TimezoneNotFound):
        tz_path('Invalid')