Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Willemsen committed Feb 13, 2025
1 parent 5fa476b commit 63d5cdb
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_script_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from __future__ import absolute_import

import builtins
import contextlib
import io
import os
import shutil
import sys
Expand Down Expand Up @@ -612,3 +614,22 @@ def test_GIVEN_unused_import_WHEN_pyright_script_checker_called_THEN_no_error(se
self.checker, self.machine, script_lines, no_pylint=True
) as errors:
self.assertEqual(errors, [])

def test_GIVEN_scanning_instrument_WHEN_calling_pylint_THEN_pylint_does_not_crash(self):
# Pylint should not complain about this as the method from a class
# deriving from "ScanningInstrument" should get added to it's parents'
# locals by the scanning_instrument_pylint_plugin.
script_lines = [
"class ScanningInstrument(): pass\n",
"class Larmor(ScanningInstrument):\n",
" def foo(self): pass\n",
]

captured_stderr = io.StringIO()
with contextlib.redirect_stderr(captured_stderr):
with CreateTempScriptAndReturnErrors(
self.checker, self.machine, script_lines
) as errors:
self.assertEqual(errors, [])

self.assertEqual(captured_stderr.getvalue(), "")

0 comments on commit 63d5cdb

Please sign in to comment.