You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
834 B

  1. # coding: utf-8
  2. # @ 2016 Florian da Costa @ Akretion
  3. # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
  4. import openerp.tests.common as common
  5. from openerp import api
  6. from StringIO import StringIO
  7. class ContextualStringIO(StringIO):
  8. """
  9. snippet from http://bit.ly/1HfH6uW (stackoverflow)
  10. """
  11. def __enter__(self):
  12. return self
  13. def __exit__(self, *args):
  14. self.close()
  15. return False
  16. class TestConnection(common.TransactionCase):
  17. def setUp(self):
  18. super(TestConnection, self).setUp()
  19. self.registry.enter_test_mode()
  20. self.env = api.Environment(self.registry.test_cr, self.env.uid,
  21. self.env.context)
  22. def tearDown(self):
  23. self.registry.leave_test_mode()
  24. super(TestConnection, self).tearDown()