#32831: Some cache tests are flaky (e.g. cache.tests.BaseMemcachedTests.test_touch) -------------------------------------+------------------------------------- Reporter: Chris Jerdonek | Owner: Wassef Type: | Ben Ahmed Cleanup/optimization | Status: assigned Component: Core (Cache system) | Version: dev Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Comment (by Wassef Ben Ahmed):
to my understanding, so far we don't know which tests exactly are flaky. mainly the cases mentioned above, and anything that uses a shared medium. as the @Simon Charette suggested this could be done by figuring out where to set locks, which he also pointed out that it might get tricky depending on how djangoci works (I have no clue) we might need to handle lock depending on the platform running the test or use something like "portalocker" which covers cross-platform locks but forces the adoption of a new dependency? expanding on a previous answer by @Chris Jerdonek on setting assertion retries, why not set it at a unit level instead of individual assertion? how you'd typically do with some pytest extensions... And we'll be assured the whole test passed without having to reason line-by-line on what went wrong? implementation goes something like: {{{ from functools import wraps def retry(retries=3, delay=1): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): attempts = 0 while attempts < retries: try: return func(*args, **kwargs) except AssertionError as e: attempts += 1 if attempts >= retries: raise time.sleep(delay) return wrapper return decorator }}} only catching/retrying on "AssertionError" so other exceptions are not permitted. which I'm still not sure about? (maybe a shared medium causes you to pluck a None or something...) -- Ticket URL: <https://code.djangoproject.com/ticket/32831#comment:17> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/010701908cfed5b1-af272b91-343c-4ba6-88f8-7255d19ed15a-000000%40eu-central-1.amazonses.com.