Commits

Jason R. Coombs committed cc8ef64 Draft

Adding some test commands that are loaded (as plugins) by the test pmxbot instance

Comments (0)

Files changed (3)

tests/functional/__init__.py

 		except OSError:
 			py.test.skip("Unable to launch irc server (tclsh must be in the path)")
 		time.sleep(0.5)
+		# add './plugins' to the path so we get some pmxbot commands specific
+		#  for testing.
+		env = os.environ.copy()
+		env['PYTHONPATH'] = os.path.join(path, 'plugins')
 		try:
 			# Launch pmxbot using Python directly (rather than through
 			#  the console entry point, which can't be properly
 			#  .terminate()d on Windows.
 			cls.bot = subprocess.Popen([sys.executable, '-c',
-				'from pmxbot.pmxbot import run; run()', configfile],)
+				'from pmxbot.pmxbot import run; run()', configfile],
+				env=env)
 		except OSError:
 			py.test.skip("Unable to launch pmxbot (pmxbot must be installed)")
 		time.sleep(5)

tests/functional/plugins/pmxbot_test_commands.egg-info/entry_points.txt

+[pmxbot_handlers]
+pmxbot functional test commands = pmxbot_test_commands

tests/functional/plugins/pmxbot_test_commands.py

+from pmxbot import botbase
+
+@botbase.command("crashnow", doc="Crash now!")
+def crash_immediately(client, event, channel, nick, rest):
+	raise TypeError("You should never call this!")
+
+@botbase.command("crashiter", doc="Crash in iterator!")
+def crash_in_iterator(client, event, channel, nick, rest):
+	raise TypeError("You should never call this!")
+	yield "You can't touch this"