def import_from_script_in_same_dir(): from foobar import foo, bar foo() bar() # Alternative import way import foobar foobar.foo() foobar.bar()
def test_foo(): assert foobar.foo() == 'foo'
print("File Name: {}\nModule Name: {}".format( __file__, __name__)) # print __file__ and __name__ print("\nSymbol Table 1 {}\n{}:".format(__file__, dir())) # names in current scope import foobar print("\nSymbol Table 2 {}\n{}:".format(__file__, dir())) # names in current scope after import of foobar print("\nSymbol Table 3 {}\n{}:".format(__file__, dir(foobar))) # names in foobar print() foobar.foo() # call functions in foobar.py as foobar.foo() foobar.bar()
def test_foo(): assert foo() == "foo"
print("File Name: {} Module Name: {}".format(__file__, __name__)) print("\nSymbol Table 1 {} {}:".format(__file__, dir())) # names in current scope import foobar print("\nSymbol Table 2 {} {}:".format(__file__, dir())) # names in current scope print("\nSymbol Table 3 {} {}:".format(__file__, dir(foobar))) # names in foobar foobar.foo() foobar.bar()
def test_foo(): with my_app.test_client() as c: rv = c.get('/foo') assert rv.status_code == 200 and rv.data.decode() == foobar.foo()
for i in range(1, 600): log.info(io.recvline()) challenge = io.recvlineS() log.info(challenge) if 'foo' in challenge: match = re.search('foo\((\?|\d+), (\?|\d+)\) = (\?|\d+)', challenge) args = [None if a == '?' else int(a) for a in match.groups()] # Iterations 50 and up contain flag information if i >= 50: if match.groups().index('?') == 1: set_flag_char(i, args[0], args[1], args[2]) # x is random_int elif match.groups().index('?') == 0: set_flag_char(i, args[0], args[1], args[2]) # y is random_int else: # skip this case for now, don't want to do the extra math pass io.sendline(str(foo(*args))) elif 'bar' in challenge: match = re.search('bar\((\?|\d+), (\?|\d+), (\?|\d+)\) = (\?|\d+)', challenge) args = [None if a == '?' else int(a) for a in match.groups()] io.sendline(str(bar(*args))) log.info(io.recvline()) io.close() display_flag_candidate()
def test_foo1(self): self.assertEqual(foo(1, 2), 3) self.assertEqual(foo(1, 3), 4)