コード例 #1
0
ファイル: test_noqa.py プロジェクト: priyakoth/pants
  def setUp(self):
    """Setup PythonCheckStyleTask with Rage Checker"""
    super(TestPyStyleTask, self).setUp()
    PythonCheckStyleTask.clear_plugins()
    PythonCheckStyleTask.register_plugin(name='angry_test', checker=Rage)

    self.style_check = self._create_task()
    self.style_check.options.suppress = None
コード例 #2
0
ファイル: test_noqa.py プロジェクト: youprofit/pants
    def setUp(self):
        """Setup PythonCheckStyleTask with Rage Checker"""
        super(TestPyStyleTask, self).setUp()
        PythonCheckStyleTask.clear_plugins()
        PythonCheckStyleTask.register_plugin(name='angry_test', checker=Rage)

        self.style_check = self._create_task()
        self.style_check.options.suppress = None
コード例 #3
0
ファイル: test_noqa.py プロジェクト: areitz/pants
  def setUp(self):
    """Setup PythonCheckStyleTask with Rage Checker"""
    super(TestPyStyleTask, self).setUp()

    PythonCheckStyleTask.options_scope = 'py.check'
    self.style_check = PythonCheckStyleTask(self._create_context(), ".")
    self.style_check._plugins = [{'name': 'Troll', 'checker': Rage}]
    self.style_check.options.suppress = None
コード例 #4
0
ファイル: test_noqa.py プロジェクト: Gabriel439/pants
class TestPyStyleTask(PythonTaskTestBase):
  @classmethod
  def task_type(cls):
    """Required method"""
    return PythonCheckStyleTask

  def _create_context(self, target_roots=None):
    return self.context(
      options={
        'py.check': {
          'interpreter': 'python'  # Interpreter required by PythonTaskTestBase
        }
      },
      target_roots=target_roots)

  def setUp(self):
    """Setup PythonCheckStyleTask with Rage Checker"""
    super(TestPyStyleTask, self).setUp()
    PythonCheckStyleTask.clear_plugins()
    PythonCheckStyleTask.register_plugin(name='angry_test', checker=Rage)
    PythonCheckStyleTask.options_scope = 'py.check'

    self.style_check = PythonCheckStyleTask(self._create_context(), ".")
    self.style_check.options.suppress = None

  def test_noqa_line_filter_length(self):
    """Verify the number of lines filtered is what we expect"""
    nits = list(self.style_check.get_nits(self.no_qa_line))
    assert len(nits) == 1, ('Actually got nits: {}'.format(
      ' '.join('{}:{}'.format(nit._line_number, nit) for nit in nits)
    ))

  def test_noqa_line_filter_code(self):
    """Verify that the line we see has the correct code"""
    nits = list(self.style_check.get_nits(self.no_qa_line))
    assert nits[0].code == 'T999', 'Not handling the code correctly'

  def test_noqa_file_filter(self):
    """Verify Whole file filters are applied correctly"""
    nits = list(self.style_check.get_nits(self.no_qa_file))
    assert len(nits) == 0, 'Expected zero nits since entire file should be ignored'