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))
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
def test_get_locale_formats(language): with override(language): assert isinstance(get_locale_formats(), Format)