def test_zulu_span_frame_error(): frame = "temp" dt = Zulu(2015, 4, 4, 12, 30) with pytest.raises(ValueError) as exc: dt.span(frame) assert "Time frame must be one of" in str(exc.value) assert "not '{0}'".format(frame)
def test_datetime_span_frame_error(): frame = 'temp' dt = Zulu(2015, 4, 4, 12, 30) with pytest.raises(ValueError) as exc: dt.span(frame) assert 'Time frame must be one of' in str(exc.value) assert "not '{0}'".format(frame)
def test_datetime_now_is_utcnow(factory): dt = Zulu.now() expected = factory() # NOTE: Intentionally skip comparison to microsecond since they will almost # always be different. assert dt.year == expected.year assert dt.month == expected.month assert dt.day == expected.day assert dt.hour == expected.hour assert dt.minute == expected.minute assert dt.second == expected.second
def test_zulu_now_is_utcnow(factory): dt = Zulu.now() expected = factory() # NOTE: Intentionally skip comparison to microsecond since they will almost # always be different. assert dt.year == expected.year assert dt.month == expected.month assert dt.day == expected.day assert dt.hour == expected.hour assert dt.minute == expected.minute assert dt.second == expected.second
def test_zulu_fromordinal(): assert Zulu.fromordinal(730120) == Zulu(2000, 1, 1)
tzinfo=UTC)), ( { "year": 2000, "month": 1, "day": 1, "hour": 12, "minute": 0, "second": 0, "tzinfo": "UTC+2359", }, datetime(1999, 12, 31, 12, 1, tzinfo=UTC), ), (0, datetime(1970, 1, 1, tzinfo=UTC)), (datetime(2000, 1, 1, tzinfo=UTC), datetime(2000, 1, 1, tzinfo=UTC)), (Zulu(2000, 1, 1), datetime(2000, 1, 1, tzinfo=UTC)), ], ) def test_zulu_parse(obj, expected): assert Zulu.parse(obj) == expected @parametrize( "string,kargs,exception", [ ("2000/01/01", {}, ParseError), ("01/01/2000", {}, ParseError), ("01-01-2000", {}, ParseError), ("2000-01-01X00:00:00", {}, ParseError), ("2000-01-01T00,00,00", {}, ParseError), ("2000-01-01T00:00:00+2400", {}, ParseError),
def test_datetime_parse(string, expected): assert Zulu.parse(string) == expected
def test_datetime_fromlocaltime(): now = localtime() assert Zulu.fromlocaltime(now).timestamp() == mktime(now)
def test_datetime_strptime(string, fmt, expected): assert Zulu.strptime(string, fmt) == expected
def test_datetime_range_error(frame, start, end): with pytest.raises(ParseError): list(Zulu.range(frame, start, end))
def test_zulu_time_to_now(): assert Zulu.now().shift(minutes=1).time_to_now() == '1 minute ago' assert Zulu.now().shift(minutes=-1).time_to_now() == 'in 1 minute'
def test_zulu_defaults(): assert Zulu() == Zulu.fromtimestamp(0) assert create() == Zulu()
def test_zulu_parse_invalid(string, kargs, exception): with pytest.raises(exception): Zulu.parse(string, **kargs)
def test_zulu_pickle(): dt = Zulu() unpickled = pickle.loads(pickle.dumps(dt)) assert isinstance(unpickled, Zulu) assert unpickled == dt
def test_zulu_is_leap_year(year, expected): assert Zulu(year).is_leap_year() == expected
def test_zulu_range_error(frame, start, end): with pytest.raises(ParseError): list(Zulu.range(frame, start, end))
def test_zulu_range(frame, start, end, expected): time_range = list(Zulu.range(frame, start, end)) assert time_range == expected
def test_zulu_copy(): dt = Zulu(2000, 1, 1) copy = dt.copy() assert copy is not dt assert copy == dt
def test_zulu_as_int(): tm = 1498672470.4801 dt = Zulu.fromtimestamp(tm) assert int(dt) == int(tm)
def test_zulu_parse_format(string, kargs, expected): assert Zulu.parse(string, **kargs) == expected
def test_datetime_span_range(frame, start, end, expected): span_range = [] for time_span in Zulu.span_range(frame, start, end): span_range.append(time_span) assert span_range == expected
def test_zulu_parse_pattern_mapping(string, pattern): pat_dt = Zulu.parse(string, DATE_PATTERN_TO_DIRECTIVE[pattern]) dt = Zulu.parse(string, pattern) assert pat_dt == dt
def test_datetime_defaults(): assert Zulu() == Zulu.fromtimestamp(0) assert create() == Zulu()
def test_zulu_strptime(string, fmt, expected): assert Zulu.strptime(string, fmt) == expected
def test_datetime_fromgmtime(struct, expected): assert Zulu.fromgmtime(struct) == expected
def test_zulu_fromdatetime(dt, expected): assert Zulu.fromdatetime(dt) == expected
def test_zulu_parse(obj, expected): assert Zulu.parse(obj) == expected
def test_zulu_fromgmtime(struct, expected): assert Zulu.fromgmtime(struct) == expected
def test_datetime_parse_invalid(string, kargs, exception): with pytest.raises(exception): Zulu.parse(string, **kargs)
def test_zulu_fromordinal(): assert Zulu.fromordinal(730120) == Zulu(2000, 1, 1)
def test_zulu_fromgmtime(struct, expected): assert Zulu.fromgmtime(struct) == expected
def test_zulu_fromlocaltime(): now = localtime() assert Zulu.fromlocaltime(now).timestamp() == mktime(now)
def test_zulu_fold(dt, timezone, expected_fold): zoned = dt.astimezone(timezone) assert zoned.fold == expected_fold assert dt == Zulu.fromdatetime(zoned)
def test_zulu_combine(date, time, expected): dt = Zulu.combine(date, time) assert dt == expected
def test_zulu_as_float(): tm = 1498672470.4801 dt = Zulu.fromtimestamp(tm) assert '{:.4f}'.format(float(dt)) == '{:.4f}'.format(tm)
def test_zulu_fold(dt, timezone, expected_fold): zoned = dt.astimezone(timezone) assert zoned.fold == expected_fold assert dt == Zulu.fromdatetime(zoned)
def test_zulu_datetuple(): dt = Zulu(2000, 1, 2, 3, 4, 5, 6, UTC) dtt = dt.datetuple() assert dtt == (2000, 1, 2)
def test_zulu_copy(): dt = Zulu(2000, 1, 1) copy = dt.copy() assert copy is not dt assert copy == dt
def test_zulu_parse(obj, expected): assert Zulu.parse(obj) == expected
def test_zulu_as_string(): dt = Zulu(2000, 1, 1) assert str(dt) == dt.isoformat()
def test_datetime_range(frame, start, end, expected): time_range = list(Zulu.range(frame, start, end)) assert time_range == expected
def test_zulu_as_float(): tm = 1498672470.4801 dt = Zulu.fromtimestamp(tm) assert "{:.4f}".format(float(dt)) == "{:.4f}".format(tm)
def test_datetime_parse_format(string, kargs, expected): assert Zulu.parse(string, **kargs) == expected
def test_zulu_as_int(): tm = 1498672470.4801 dt = Zulu.fromtimestamp(tm) assert int(dt) == int(tm)
def test_datetime_parse_pattern_mapping(string, pattern): pat_dt = Zulu.parse(string, DATE_PATTERN_TO_DIRECTIVE[pattern]) dt = Zulu.parse(string, pattern) assert pat_dt == dt
def test_zulu_datetuple(): dt = Zulu(2000, 1, 2, 3, 4, 5, 6, UTC) dtt = dt.datetuple() assert dtt == (2000, 1, 2)
def test_datetime_fromdatetime(dt, expected): assert Zulu.fromdatetime(dt) == expected
def test_datetime_combine(date, time, expected): dt = Zulu.combine(date, time) assert dt == expected
def test_datetime_fromordinal(): assert Zulu.fromordinal(730120) == Zulu(2000, 1, 1)
def test_datetime_as_string(): dt = Zulu(2000, 1, 1) assert str(dt) == dt.isoformat()
def test_zulu_string_format(): dt = Zulu(2000, 1, 1) assert "{0}".format(dt) == dt.isoformat() assert "{0:%Y-%m-%dT%H:%M:%S}".format(dt) == dt.format("%Y-%m-%dT%H:%M:%S")
def test_zulu_span_range(frame, start, end, expected): span_range = [] for time_span in Zulu.span_range(frame, start, end): span_range.append(time_span) assert span_range == expected
def test_datetime_copy(): dt = Zulu(2000, 1, 1) copy = dt.copy() assert copy is not dt assert copy == dt
def test_zulu_addition_invalid_type(): with pytest.raises(TypeError): Zulu() + "string"
def test_datetime_string_format(): dt = Zulu(2000, 1, 1) assert '{0}'.format(dt) == dt.isoformat() assert '{0:%Y-%m-%dT%H:%M:%S}'.format(dt) == dt.format('%Y-%m-%dT%H:%M:%S')
def test_zulu_time_from_now(): assert Zulu.now().shift(minutes=1).time_from_now() == "in 1 minute" assert Zulu.now().shift(minutes=-1).time_from_now() == "1 minute ago"
def test_datetime_time_from_now(): assert Zulu.now().shift(minutes=1).time_from_now() == 'in 1 minute' assert Zulu.now().shift(minutes=-1).time_from_now() == '1 minute ago'
def test_zulu_hash(): dt = Zulu(2000, 1, 1) assert hash(dt) == hash(datetime(2000, 1, 1, tzinfo=UTC))
def test_zulu_span_range_error(frame, start, end): with pytest.raises(ParseError): list(Zulu.span_range(frame, start, end))
print(foodobject.score[0]) c.choosing_criteria(foodobject, food) def get_substitued_aliments(self): """Print all substituted aliments""" substitutelst = S.get_substitued() newsubstitutelst = [] for x in substitutelst: newsubstitutelst.append(list(x)) i = 0 while i < len(newsubstitutelst): print("Vous avez remplacé {0} par {1} \nUrl du produit original : " "{2}\nUrl du nouveau produit : {3}".format( newsubstitutelst[i][0], newsubstitutelst[i][2], c.get_url_cleaned(newsubstitutelst[i][1]), c.get_url_cleaned(newsubstitutelst[i][3]) ) ) i += 1 def get_url_cleaned(self, url): producturl = url.replace("api/v0/", "") return producturl c = Criteria() z = Zulu() S = Sqlfunc() su = Submenu()