| 757 | @pytest.mark.smoke |
| 758 | @pytest.mark.tzoffset |
| 759 | def test_tzoffset_weakref(): |
| 760 | UTC1 = tz.tzoffset('UTC', 0) |
| 761 | UTC_ref = weakref.ref(tz.tzoffset('UTC', 0)) |
| 762 | UTC1 is UTC_ref() |
| 763 | del UTC1 |
| 764 | gc.collect() |
| 765 | |
| 766 | assert UTC_ref() is not None # Should be in the strong cache |
| 767 | assert UTC_ref() is tz.tzoffset('UTC', 0) |
| 768 | |
| 769 | # Fill the strong cache with other items |
| 770 | for offset in range(5,15): |
| 771 | tz.tzoffset('RandomZone', offset) |
| 772 | |
| 773 | gc.collect() |
| 774 | assert UTC_ref() is None |
| 775 | assert UTC_ref() is not tz.tzoffset('UTC', 0) |
| 776 | |
| 777 | |
| 778 | @pytest.mark.tzoffset |