conftest.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import pytest
  2. @pytest.fixture
  3. def syntax_error_py_file(tmp_path):
  4. file_content = """
  5. def foo():
  6. print("Hello, World!")
  7. print("Wrong indent")
  8. foo(
  9. """
  10. file_path = tmp_path / 'test_file.py'
  11. file_path.write_text(file_content)
  12. return str(file_path)
  13. @pytest.fixture
  14. def wrongly_indented_py_file(tmp_path):
  15. file_content = """
  16. def foo():
  17. print("Hello, World!")
  18. """
  19. file_path = tmp_path / 'test_file.py'
  20. file_path.write_text(file_content)
  21. return str(file_path)
  22. @pytest.fixture
  23. def simple_correct_py_file(tmp_path):
  24. file_content = 'print("Hello, World!")\n'
  25. file_path = tmp_path / 'test_file.py'
  26. file_path.write_text(file_content)
  27. return str(file_path)
  28. @pytest.fixture
  29. def simple_correct_py_func_def(tmp_path):
  30. file_content = """def foo():
  31. print("Hello, World!")
  32. foo()
  33. """
  34. file_path = tmp_path / 'test_file.py'
  35. file_path.write_text(file_content)
  36. return str(file_path)
  37. @pytest.fixture
  38. def simple_correct_ruby_file(tmp_path):
  39. file_content = """def foo
  40. puts "Hello, World!"
  41. end
  42. foo
  43. """
  44. file_path = tmp_path / 'test_file.rb'
  45. file_path.write_text(file_content)
  46. return str(file_path)
  47. @pytest.fixture
  48. def simple_incorrect_ruby_file(tmp_path):
  49. file_content = """def foo():
  50. print("Hello, World!")
  51. foo()
  52. """
  53. file_path = tmp_path / 'test_file.rb'
  54. file_path.write_text(file_content)
  55. return str(file_path)
  56. @pytest.fixture
  57. def parenthesis_incorrect_ruby_file(tmp_path):
  58. file_content = """def print_hello_world()\n puts 'Hello World'\n"""
  59. file_path = tmp_path / 'test_file.rb'
  60. file_path.write_text(file_content)
  61. return str(file_path)