Files
lutris/tests/util/_test_init.py
Daniel Johnson 4d0641e50b Rename the world! All unit tests will start with '_test_' to avoid ambiguity. This means stuff like 'test_config.py' will no longer be loaded as test module.
This means that very module must be explicitly loaded by various tests that need the 'gi.requires_versions' part- they no longer sometimes get this by accident (sometimes).

In turn, _test_cloud_save_progress will no longer stub stuff in sys.modules, which is awful- it breaks later tests. That in turns makes it much chattier since it now actually logs stuff. But it seems to pass for all that.

Yikes!

Resolves #6570

Much research and drudgery done by Claude Code 🤖 before it clocked out.
2026-03-24 09:20:25 -04:00

33 lines
755 B
Python

import unittest
from lutris.util import cache_single
class TestCacheSingle(unittest.TestCase):
def test_no_args(self):
call_count = 0
@cache_single
def no_args():
nonlocal call_count
call_count += 1
return call_count
self.assertEqual(no_args(), 1)
self.assertEqual(no_args(), 1)
no_args.cache_clear()
self.assertEqual(no_args(), 2)
self.assertEqual(no_args(), 2)
def test_with_args(self):
@cache_single
def with_args(return_value):
return return_value
self.assertEqual(with_args(1), 1)
self.assertEqual(with_args(2), 2)
with_args.cache_clear()
self.assertEqual(with_args(3), 3)