Exemplo n.º 1
0
def test_local_date_timesince(settings):
    timestamp = time.time() - 1000000
    timedelta = datetime.now() - datetime.fromtimestamp(timestamp)
    language = str(get_locale_formats().locale)
    assert timesince(timestamp) == format_timedelta(timedelta, locale=language)
    assert (timesince(timestamp,
                      locale="ff") == timesince(timestamp,
                                                locale=settings.LANGUAGE_CODE))
Exemplo n.º 2
0
def test_local_date_timesince_wrong_locale(language, fallback):
    timestamp = time.time() - 1000000
    timedelta = datetime.now() - datetime.fromtimestamp(timestamp)
    fallback_format = get_locale_formats(fallback)
    fallback_timedelta = fallback_format.timedelta(timedelta, format='long')
    assert timesince(timestamp, locale=language) == fallback_timedelta
Exemplo n.º 3
0
def test_get_locale_formats(language):
    with override(language):
        assert isinstance(get_locale_formats(), Format)