__init__.py 998 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import os
  2. import aiounittest
  3. os.environ['SEARX_DEBUG'] = '1'
  4. os.environ['SEARX_DEBUG_LOG_LEVEL'] = 'WARNING'
  5. os.environ['SEARX_DISABLE_ETC_SETTINGS'] = '1'
  6. os.environ.pop('SEARX_SETTINGS_PATH', None)
  7. class SearxTestLayer:
  8. """Base layer for non-robot tests."""
  9. __name__ = 'SearxTestLayer'
  10. @classmethod
  11. def setUp(cls):
  12. pass
  13. @classmethod
  14. def tearDown(cls):
  15. pass
  16. @classmethod
  17. def testSetUp(cls):
  18. pass
  19. @classmethod
  20. def testTearDown(cls):
  21. pass
  22. class SearxTestCase(aiounittest.AsyncTestCase):
  23. """Base test case for non-robot tests."""
  24. layer = SearxTestLayer
  25. def setattr4test(self, obj, attr, value):
  26. """
  27. setattr(obj, attr, value)
  28. but reset to the previous value in the cleanup.
  29. """
  30. previous_value = getattr(obj, attr)
  31. def cleanup_patch():
  32. setattr(obj, attr, previous_value)
  33. self.addCleanup(cleanup_patch)
  34. setattr(obj, attr, value)