Skip to content

Instantly share code, notes, and snippets.

@SiD3W4y
Created February 23, 2018 20:16
Show Gist options
  • Save SiD3W4y/64eef0ffac31dcdb5dbc03aadaa083f0 to your computer and use it in GitHub Desktop.
Save SiD3W4y/64eef0ffac31dcdb5dbc03aadaa083f0 to your computer and use it in GitHub Desktop.
import unittest without using any obvious method, could be used to fake tests using unittest for automatic grading (theorically and with further improvement)
# it is the bytecode used in the code constructor
#def s():
# import unittest as m
# return m
# we need a dummy function to inject the code object in it
def dummy():
pass
dummy.__code__=type(dummy.__code__)(0,0,1,2,67,b'd\x01d\x00l\x00}\x00|\x00S\x00',(None,0),('unittest',),('m',),'','',1,b'\x00\x01\x08\x01')
# Should print <class 'unittest.case.TestCase'>
print(dummy().TestCase)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment