Exemple #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')
Exemple #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)
Exemple #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)
Exemple #4
0
def test_tz_path_empty_string():
    with pytest.raises(ValueError):
        tz_path('')
Exemple #5
0
def test_tz_path_invalid_name():
    with pytest.raises(ValueError):
        tz_path('Europe/../Paris')
Exemple #6
0
def test_tz_path_not_found():
    with pytest.raises(TimezoneNotFound):
        tz_path('Invalid')