Changes between Initial Version and Version 1 of Ticket #31944


Ignore:
Timestamp:
Aug 26, 2020, 2:55:24 AM (4 years ago)
Author:
François Freitag
Comment:

Clarified ordering issue with comments in the example code.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31944 – Description

    initial v1  
    1010
    1111    def enable(self):
     12        # 1. Before setUp, TestContextDecorator runs enable().
    1213        cm = override_settings(CSRF_COOKIE_NAME="cross_site_request_forgery_token")
    1314        self.stack.enter_context(cm)
    1415
    1516    def disable(self):
     17        # 3. After tearDown, TestContextDecorator runs disable(), which restores settings captured in 1.
     18        # This should be step 4.
    1619        self.stack.close()
    1720
     
    2023    def setUp(self):
    2124        super().setUp()
     25        # 2. Capture settings after they’ve been changed in 1.
    2226        settings_cm = self.settings(CACHES={})
    2327        settings_cm.enable()
    24         self.addCleanup(settings_cm.disable)
     28        self.addCleanup(settings_cm.disable)  # 4. Restore settings captured in 2. Should be executed at step 3.
    2529
    2630
Back to Top