# A quick test to demonstrate the libraries directory scheme. # # imports and tests PyBBIO/libraries/example.py try: import example except: print "\nWe can't import the PyBBIO library until we've imported bbio" print "Importing bbio" from bbio import * print "now we can import example" import example print "testing example library:" example.foo()
# A quick test to demonstrate the libraries directory scheme. # # imports and tests PyBBIO/libraries/example.py try: import example except: print "\nWe can't import the PyBBIO library until we've imported bbio" print "Importing bbio" from bbio import * print "now we can import example" from bbio.libraries import example print "testing example library:" example.foo()
def test_foo(): assert foo(a=None) is None assert foo(False) is True assert foo(True) is False
import os.path, sys import distutils.util # Append the directory in which the binaries were placed to Python's sys.path, # then import the D DLL. libDir = os.path.join( 'build', 'lib.%s-%s' % (distutils.util.get_platform(), '.'.join( str(v) for v in sys.version_info[:2]))) sys.path.append(os.path.abspath(libDir)) import example example.foo(100) example.bar1(1) example.bar2("seven") example.baz() example.baz(s="cow")
s, o = example.sum_of_digits(17, 10, ()) assert_eq(s, 8) assert_is(o, False) s, o = example.sum_of_digits(1337, 10, ...) assert_eq(s, 14) assert_is(o, True) assert_eq(example.sign([]), -1) assert_eq(example.sign(-1.0), 1) # sign(bool) assert_true(example.sign(-1)) # trigger sign(int) assert_true(example.is_even({})) assert_false(example.is_even(range(12))) assert_false(example.is_even(int)) assert_true(example.is_even(10)) class A: def __bool__(self): raise Exception('A error') with AssertError(text='A error'): example.is_ok(A()) assert_eq(example.foo("hi"), 1) assert_eq(example.foo(""), 1) assert_eq(example.foo(2.0), 2) assert_eq(example.foo(True), 2)
def test_foo_returns_sum(self): """Test normal generation of ClusterName""" f = foo(1,1) self.assertEquals(f,2)
import os.path, sys import distutils.util # Append the directory in which the binaries were placed to Python's sys.path, # then import the D DLL. libDir = os.path.join('build', 'lib.%s-%s' % ( distutils.util.get_platform(), '.'.join(str(v) for v in sys.version_info[:2]) )) sys.path.append(os.path.abspath(libDir)) import example example.foo(100) example.bar1(1) example.bar2("seven") example.baz() example.baz(s="cow")
import example l = [1,2,3] # example.doubleEach(l) print(example.doubled(l)) print(example.doubled(x for x in range(4))) print(l) example.doubleEach(l) print(l) ts = example.TestStruct(3) print(repr(ts)) example.kwarg_parrot(voltage=480000, state='a stiff', action='voom', type='Norwegian Blue') # example.printEach(l) example.foo('hey') # example.kwarg_parrot # print(l) #