# Path: mozz/test.py
# def run_test_module(name, file):
# 	outputfile = mozz.util.python_path_basename(file) + '.out'
# 
# 	m = sys.modules[name]
# 	ldr = unittest.loader.defaultTestLoader
# 	tests = ldr.loadTestsFromModule(m)
# 
# 	with open(outputfile, 'w') as f:
# 		duper = mozz.util.IOWriteDuplicator(
# 			sys.stderr, f
# 		)
# 		unittest.runner.TextTestRunner(
# 			verbosity = 2,
# 			stream = duper
# 		).run(tests)
# 
# def abs_path(base_file, rel_path):
# 	return os.path.join(
# 		os.path.dirname(os.path.abspath(base_file)),
# 		rel_path
# 	)


import unittest
import mozz
import mozz.sig
from mozz.test import run_test_module, abs_path
		s.del_cb_finish(finish)

		main1_first = [0]
		@s.at_addr("main")
		def main(host):
			d['main'] += 1
			main1_first[0] += 1
			s.del_addr_cb_fn("main", main)

		@s.at_addr("main")
		def main2(host):
			d['main2'] += 1
			self.assertEqual(main1_first[0], 1)

		mozz.run_session(s)

		self.assertEqual(s.iteration(), 3)
		self.assertEqual(d['on_pre'], 1)
		self.assertEqual(d['on_post'], 1)
		self.assertEqual(d['at_entry'], 1)
		self.assertEqual(d['on_run'], 0)
		self.assertEqual(d['on_finish'], 0)
		self.assertEqual(d['on_sigint'], 1)
		self.assertEqual(d['on_sig_default'], 1)
		self.assertEqual(d['on_start'], 1)
		self.assertEqual(d['on_start2'], 3)
		self.assertEqual(d['on_exit'], 1)
		self.assertEqual(d['main'], 1)
		self.assertEqual(d['main2'], 3)


# Path: mozz/test.py
# def run_test_module(name, file):
# 	outputfile = mozz.util.python_path_basename(file) + '.out'
# 
# 	m = sys.modules[name]
# 	ldr = unittest.loader.defaultTestLoader
# 	tests = ldr.loadTestsFromModule(m)
# 
# 	with open(outputfile, 'w') as f:
# 		duper = mozz.util.IOWriteDuplicator(
# 			sys.stderr, f
# 		)
# 		unittest.runner.TextTestRunner(
# 			verbosity = 2,
# 			stream = duper
# 		).run(tests)
# 
# def abs_path(base_file, rel_path):
# 	return os.path.join(
# 		os.path.dirname(os.path.abspath(base_file)),
# 		rel_path
# 	)


# Path: test/cb_remove_test.py
import unittest
import mozz
import mozz.sig
from mozz.test import run_test_module, abs_path

		s.del_cb_finish(finish)

		main1_first = [0]
		@s.at_addr("main")
		def main(host):
			d['main'] += 1
			main1_first[0] += 1
			s.del_addr_cb_fn("main", main)

		@s.at_addr("main")
		def main2(host):
			d['main2'] += 1
			self.assertEqual(main1_first[0], 1)

		mozz.run_session(s)

		self.assertEqual(s.iteration(), 3)
		self.assertEqual(d['on_pre'], 1)
		self.assertEqual(d['on_post'], 1)
		self.assertEqual(d['at_entry'], 1)
		self.assertEqual(d['on_run'], 0)
		self.assertEqual(d['on_finish'], 0)
		self.assertEqual(d['on_sigint'], 1)
		self.assertEqual(d['on_sig_default'], 1)
		self.assertEqual(d['on_start'], 1)
		self.assertEqual(d['on_start2'], 3)
		self.assertEqual(d['on_exit'], 1)
		self.assertEqual(d['main'], 1)
		self.assertEqual(d['main2'], 3)


run_test_module(__name__, __file__)