testExceptions.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2014 Modelling, Simulation and Design Lab (MSDL) at
  2. # McGill University and the University of Antwerp (http://msdl.cs.mcgill.ca/)
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. from testutils import *
  16. from pypdevs.util import DEVSException
  17. from pypdevs.DEVS import BaseDEVS, AtomicDEVS, CoupledDEVS
  18. class TestExceptions(unittest.TestCase):
  19. # Tests the externalInput function, which takes messages of the form:
  20. # [[time, age], content, anti-message, UUID, color]
  21. def setUp(self):
  22. self.sim = basicSim()
  23. def tearDown(self):
  24. self.sim.run_gvt = False
  25. def test_DEVS_model_exceptions(self):
  26. try:
  27. # Shouldn't allow instantiation of the base model
  28. junk = BaseDEVS("junk")
  29. self.fail() #pragma: nocover
  30. except DEVSException:
  31. pass
  32. try:
  33. # Shouldn't allow instantiation of the base model
  34. junk = AtomicDEVS("junk")
  35. self.fail() #pragma: nocover
  36. except DEVSException:
  37. pass
  38. try:
  39. # Shouldn't allow instantiation of the base model
  40. junk = CoupledDEVS("junk")
  41. self.fail() #pragma: nocover
  42. except DEVSException:
  43. pass