mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-19 10:20:56 +07:00
Reasoning to hard-code mutes: 1. Muted via TeamCity UI the tests still fail the build (see PCQA-593) 2. Muted via TeamCity UI the tests are not muted locally Tickets for muted tests ... - PCQA-591 - PCQA-592 - PCQA-697 - PCQA-698 - PCQA-699 - PCQA-700 - PCQA-702 - PCQA-703 - PCQA-704 - PCQA-705 - PCQA-706 - PCQA-707 - PCQA-708 - PCQA-709 (cherry picked from commit aefbf8129a680c8c2256462755d7306492aba4fc) IJ-MR-149693 GitOrigin-RevId: d0e782aec51b2f1a96f1c9620c2f3966075edfc3
71 lines
2.7 KiB
Python
71 lines
2.7 KiB
Python
import os
|
|
import re
|
|
import sys
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
import pytest
|
|
|
|
#=======================================================================================================================
|
|
# Test
|
|
#=======================================================================================================================
|
|
class Test(unittest.TestCase):
|
|
"""
|
|
Unittest for pydev_coverage.py.
|
|
TODO:
|
|
- 'combine' in arguments
|
|
- no 'combine' and no 'pydev-analyze' in arguments
|
|
"""
|
|
|
|
def setUp(self):
|
|
unittest.TestCase.setUp(self)
|
|
project_path = os.path.dirname(os.path.dirname(__file__))
|
|
self._resources_path = os.path.join(project_path, "pydev_tests_python", "resources")
|
|
self._coverage_file = os.path.join(project_path, "pydev_coverage.py")
|
|
|
|
def _do_analyze(self, files):
|
|
invalid_files = []
|
|
|
|
p = subprocess.Popen(["python", self._coverage_file, "--pydev-analyze"],
|
|
stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
__, stderrdata = p.communicate("|".join(files).encode())
|
|
|
|
if stderrdata:
|
|
match = re.search("Invalid files not passed to coverage: (.*?)$",
|
|
stderrdata.decode(), re.M) # @UndefinedVariable
|
|
if match:
|
|
invalid_files = [f.strip() for f in match.group(1).split(",")]
|
|
return invalid_files
|
|
|
|
def test_pydev_analyze_ok(self):
|
|
ref_valid_files = [__file__,
|
|
os.path.join(self._resources_path, "_debugger_case18.py")]
|
|
ref_invalid_files = []
|
|
|
|
invalid_files = self._do_analyze(ref_valid_files)
|
|
|
|
self.assertEqual(ref_invalid_files, invalid_files)
|
|
|
|
def test_pydev_analyse_non_standard_encoding(self):
|
|
ref_valid_files = [os.path.join(self._resources_path,
|
|
"_pydev_coverage_cyrillic_encoding_py%i.py"
|
|
% sys.version_info[0])]
|
|
ref_invalid_files = []
|
|
|
|
invalid_files = self._do_analyze(ref_valid_files + ref_invalid_files)
|
|
|
|
self.assertEqual(ref_invalid_files, invalid_files)
|
|
|
|
@pytest.mark.xfail(reason="PCQA-709")
|
|
def test_pydev_analyse_invalid_files(self):
|
|
with tempfile.NamedTemporaryFile(suffix=".pyx") as pyx_file:
|
|
ref_valid_files = []
|
|
ref_invalid_files = [os.path.join(self._resources_path,
|
|
"_pydev_coverage_syntax_error.py"),
|
|
pyx_file.name]
|
|
|
|
invalid_files = self._do_analyze(ref_valid_files + ref_invalid_files)
|
|
|
|
self.assertEqual(ref_invalid_files, invalid_files)
|