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.

unittest_checker_misc.py 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Copyright (c) 2013-2014, 2016-2017 Claudiu Popa <pcmanticore@gmail.com>
  2. # Copyright (c) 2013-2014 Google, Inc.
  3. # Copyright (c) 2013-2014 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
  4. # Copyright (c) 2014 Arun Persaud <arun@nubati.net>
  5. # Copyright (c) 2015 Ionel Cristian Maries <contact@ionelmc.ro>
  6. # Copyright (c) 2016 Derek Gustafson <degustaf@gmail.com>
  7. # Copyright (c) 2016 glegoux <gilles.legoux@gmail.com>
  8. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  9. # For details: https://github.com/PyCQA/pylint/blob/master/COPYING
  10. """Tests for the misc checker."""
  11. from pylint.checkers import misc
  12. from pylint.testutils import (
  13. CheckerTestCase, Message,
  14. set_config, _create_file_backed_module,
  15. )
  16. class TestFixme(CheckerTestCase):
  17. CHECKER_CLASS = misc.EncodingChecker
  18. def test_fixme_with_message(self):
  19. with _create_file_backed_module(
  20. """a = 1
  21. # FIXME message
  22. """) as module:
  23. with self.assertAddsMessages(
  24. Message(msg_id='fixme', line=2, args=u'FIXME message')):
  25. self.checker.process_module(module)
  26. def test_todo_without_message(self):
  27. with _create_file_backed_module(
  28. """a = 1
  29. # TODO
  30. """) as module:
  31. with self.assertAddsMessages(
  32. Message(msg_id='fixme', line=2, args=u'TODO')):
  33. self.checker.process_module(module)
  34. def test_xxx_without_space(self):
  35. with _create_file_backed_module(
  36. """a = 1
  37. #XXX
  38. """) as module:
  39. with self.assertAddsMessages(
  40. Message(msg_id='fixme', line=2, args=u'XXX')):
  41. self.checker.process_module(module)
  42. def test_xxx_middle(self):
  43. with _create_file_backed_module(
  44. """a = 1
  45. # midle XXX
  46. """) as module:
  47. with self.assertNoMessages():
  48. self.checker.process_module(module)
  49. def test_without_space_fixme(self):
  50. with _create_file_backed_module(
  51. """a = 1
  52. #FIXME
  53. """) as module:
  54. with self.assertAddsMessages(
  55. Message(msg_id='fixme', line=2, args=u'FIXME')):
  56. self.checker.process_module(module)
  57. @set_config(notes=[])
  58. def test_absent_codetag(self):
  59. with _create_file_backed_module(
  60. """a = 1
  61. # FIXME
  62. # TODO
  63. # XXX
  64. """) as module:
  65. with self.assertNoMessages():
  66. self.checker.process_module(module)
  67. @set_config(notes=['CODETAG'])
  68. def test_other_present_codetag(self):
  69. with _create_file_backed_module(
  70. """a = 1
  71. # CODETAG
  72. # FIXME
  73. """) as module:
  74. with self.assertAddsMessages(
  75. Message(msg_id='fixme', line=2, args=u'CODETAG')):
  76. self.checker.process_module(module)