A Python parser for MediaWiki wikicode https://mwparserfromhell.readthedocs.io/
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 

49 行
2.0 KiB

  1. #
  2. # Copyright (C) 2012-2019 Ben Kurtovic <ben.kurtovic@gmail.com>
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. # SOFTWARE.
  21. import unittest
  22. from mwparserfromhell.parser import contexts
  23. from mwparserfromhell.parser.tokenizer import Tokenizer
  24. from ._test_tokenizer import TokenizerTestCase
  25. class TestPyTokenizer(TokenizerTestCase, unittest.TestCase):
  26. """Test cases for the Python tokenizer."""
  27. @classmethod
  28. def setUpClass(cls):
  29. cls.tokenizer = Tokenizer
  30. if not TokenizerTestCase.skip_others:
  31. def test_uses_c(self):
  32. """make sure the Python tokenizer identifies as not using C"""
  33. self.assertFalse(Tokenizer.USES_C)
  34. self.assertFalse(Tokenizer().USES_C)
  35. def test_describe_context(self):
  36. self.assertEqual("", contexts.describe(0))
  37. ctx = contexts.describe(contexts.TEMPLATE_PARAM_KEY|contexts.HAS_TEXT)
  38. self.assertEqual("TEMPLATE_PARAM_KEY|HAS_TEXT", ctx)
  39. if __name__ == "__main__":
  40. unittest.main(verbosity=2)