from unittest import TestCase, main
from grammpy.RawGrammar import RawGrammar


class NonterminalsInvalidTest(TestCase):
    pass




if __name__ == '__main__':
    main()

from unittest import TestCase, main
from grammpy.RawGrammar import RawGrammar as Grammar
from grammpy import Nonterminal
from grammpy.exceptions import NotNonterminalException


class TempClass(Nonterminal):
    pass


class NonterminalsInvalidTest(TestCase):
    def test_invalidAddNumber(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.add_nonterm(0)

    def test_invalidAddString(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.add_nonterm("string")

    def test_invalidAddAfterCorrectAdd(self):
        gr = Grammar()
        gr.add_nonterm(TempClass)
        with self.assertRaises(NotNonterminalException):
            gr.add_nonterm("asdf")

    def test_invalidAddInArray(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.add_nonterm([TempClass, "asdf"])

    def test_invalidHaveNumber(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.have_nonterm(0)

    def test_invalidHaveString(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.have_nonterm("string")

    def test_invalidHaveAfterCorrectAdd(self):
        gr = Grammar()
        gr.add_nonterm(TempClass)
        with self.assertRaises(NotNonterminalException):
            gr.have_nonterm("asdf")

    def test_invalidHaveInArray(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.have_nonterm([TempClass, "asdf"])


if __name__ == '__main__':
    main()

Add tests that have and get of nonterms raise exceptions
Add tests that have and get of nonterms raise exceptions

  from unittest import TestCase, main
- from grammpy.RawGrammar import RawGrammar
+ from grammpy.RawGrammar import RawGrammar as Grammar
+ from grammpy import Nonterminal
+ from grammpy.exceptions import NotNonterminalException
+ 
+ 
+ class TempClass(Nonterminal):
+     pass
  
  
  class NonterminalsInvalidTest(TestCase):
-     pass
+     def test_invalidAddNumber(self):
+         gr = Grammar()
+         with self.assertRaises(NotNonterminalException):
+             gr.add_nonterm(0)
  
+     def test_invalidAddString(self):
+         gr = Grammar()
+         with self.assertRaises(NotNonterminalException):
+             gr.add_nonterm("string")
  
+     def test_invalidAddAfterCorrectAdd(self):
+         gr = Grammar()
+         gr.add_nonterm(TempClass)
+         with self.assertRaises(NotNonterminalException):
+             gr.add_nonterm("asdf")
+ 
+     def test_invalidAddInArray(self):
+         gr = Grammar()
+         with self.assertRaises(NotNonterminalException):
+             gr.add_nonterm([TempClass, "asdf"])
+ 
+     def test_invalidHaveNumber(self):
+         gr = Grammar()
+         with self.assertRaises(NotNonterminalException):
+             gr.have_nonterm(0)
+ 
+     def test_invalidHaveString(self):
+         gr = Grammar()
+         with self.assertRaises(NotNonterminalException):
+             gr.have_nonterm("string")
+ 
+     def test_invalidHaveAfterCorrectAdd(self):
+         gr = Grammar()
+         gr.add_nonterm(TempClass)
+         with self.assertRaises(NotNonterminalException):
+             gr.have_nonterm("asdf")
+ 
+     def test_invalidHaveInArray(self):
+         gr = Grammar()
+         with self.assertRaises(NotNonterminalException):
+             gr.have_nonterm([TempClass, "asdf"])
  
  
  if __name__ == '__main__':
      main()
  
Add tests that have and get of nonterms raise exceptions
## Code Before:
from unittest import TestCase, main
from grammpy.RawGrammar import RawGrammar


class NonterminalsInvalidTest(TestCase):
    pass




if __name__ == '__main__':
    main()

## Instruction:
Add tests that have and get of nonterms raise exceptions
## Code After:
from unittest import TestCase, main
from grammpy.RawGrammar import RawGrammar as Grammar
from grammpy import Nonterminal
from grammpy.exceptions import NotNonterminalException


class TempClass(Nonterminal):
    pass


class NonterminalsInvalidTest(TestCase):
    def test_invalidAddNumber(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.add_nonterm(0)

    def test_invalidAddString(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.add_nonterm("string")

    def test_invalidAddAfterCorrectAdd(self):
        gr = Grammar()
        gr.add_nonterm(TempClass)
        with self.assertRaises(NotNonterminalException):
            gr.add_nonterm("asdf")

    def test_invalidAddInArray(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.add_nonterm([TempClass, "asdf"])

    def test_invalidHaveNumber(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.have_nonterm(0)

    def test_invalidHaveString(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.have_nonterm("string")

    def test_invalidHaveAfterCorrectAdd(self):
        gr = Grammar()
        gr.add_nonterm(TempClass)
        with self.assertRaises(NotNonterminalException):
            gr.have_nonterm("asdf")

    def test_invalidHaveInArray(self):
        gr = Grammar()
        with self.assertRaises(NotNonterminalException):
            gr.have_nonterm([TempClass, "asdf"])


if __name__ == '__main__':
    main()
