Development of an internal social media platform with personalised dashboards for students
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.

brain_pytest.py 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright (c) 2014-2016 Claudiu Popa <pcmanticore@gmail.com>
  2. # Copyright (c) 2016 Cara Vinson <ceridwenv@gmail.com>
  3. # Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
  4. # For details: https://github.com/PyCQA/astroid/blob/master/COPYING.LESSER
  5. """Astroid hooks for pytest."""
  6. from __future__ import absolute_import
  7. from astroid import MANAGER, register_module_extender
  8. from astroid.builder import AstroidBuilder
  9. def pytest_transform():
  10. return AstroidBuilder(MANAGER).string_build('''
  11. try:
  12. import _pytest.mark
  13. import _pytest.recwarn
  14. import _pytest.runner
  15. import _pytest.python
  16. import _pytest.skipping
  17. import _pytest.assertion
  18. except ImportError:
  19. pass
  20. else:
  21. deprecated_call = _pytest.recwarn.deprecated_call
  22. warns = _pytest.recwarn.warns
  23. exit = _pytest.runner.exit
  24. fail = _pytest.runner.fail
  25. skip = _pytest.runner.skip
  26. importorskip = _pytest.runner.importorskip
  27. xfail = _pytest.skipping.xfail
  28. mark = _pytest.mark.MarkGenerator()
  29. raises = _pytest.python.raises
  30. # New in pytest 3.0
  31. try:
  32. approx = _pytest.python.approx
  33. register_assert_rewrite = _pytest.assertion.register_assert_rewrite
  34. except AttributeError:
  35. pass
  36. # Moved in pytest 3.0
  37. try:
  38. import _pytest.freeze_support
  39. freeze_includes = _pytest.freeze_support.freeze_includes
  40. except ImportError:
  41. try:
  42. import _pytest.genscript
  43. freeze_includes = _pytest.genscript.freeze_includes
  44. except ImportError:
  45. pass
  46. try:
  47. import _pytest.debugging
  48. set_trace = _pytest.debugging.pytestPDB().set_trace
  49. except ImportError:
  50. try:
  51. import _pytest.pdb
  52. set_trace = _pytest.pdb.pytestPDB().set_trace
  53. except ImportError:
  54. pass
  55. try:
  56. import _pytest.fixtures
  57. fixture = _pytest.fixtures.fixture
  58. yield_fixture = _pytest.fixtures.yield_fixture
  59. except ImportError:
  60. try:
  61. import _pytest.python
  62. fixture = _pytest.python.fixture
  63. yield_fixture = _pytest.python.yield_fixture
  64. except ImportError:
  65. pass
  66. ''')
  67. register_module_extender(MANAGER, 'pytest', pytest_transform)
  68. register_module_extender(MANAGER, 'py.test', pytest_transform)