- GRAYBYTE UNDETECTABLE CODES -

403Webshell
Server IP : 184.154.167.98  /  Your IP : 18.220.222.188
Web Server : Apache
System : Linux pink.dnsnetservice.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64
User : puertode ( 1767)
PHP Version : 8.2.26
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/tracer/tests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/tracer/tests/test_hooks.py
from .__meta__ import *
from tracer.hooks import HooksObserver, match

called = None

@match("app1")
def hook_dummy():
	global called
	called = "dummy"

@match(["app2", "app3"])
def hook_dummy_list():
	global called
	called = "dummy_list"

@match("foo")
def hook_dummy_append1():
	global called
	called.append("foo")

@match("bar")
def hook_dummy_append2():
	global called
	called.append("bar")


class TestHooks(unittest.TestCase):

	def setUp(self):
		self.observer = HooksObserver()
		global called
		called = None

	def test_hook(self):
		self.observer("app1")
		self.assertEqual(called, "dummy")

		self.observer("app2")
		self.assertEqual(called, "dummy_list")

		self.observer("app3")
		self.assertEqual(called, "dummy_list")

	def test_hooks_list(self):
		global called
		called = []
		self.observer("foo")
		self.observer("bar")
		self.assertListEqual(called, ["foo", "bar"])

	def test_undefined_hook(self):
		global called
		self.observer("undefined")
		self.assertIsNone(called)



if __name__ == '__main__':
	unittest.main()

Youez - 2016 - github.com/yon3zu
LinuXploit