def test_macos(self): self.fs.os = OSType.MACOS path = '/foo/bar' self.assertEqual(path, os.path.join('/', 'foo', 'bar')) self.assertEqual(('', 'C:/foo/bar'), os.path.splitdrive('C:/foo/bar')) self.fs.create_file(path) self.assertTrue(os.path.exists(path)) self.assertTrue(os.path.exists(path.upper())) self.assertTrue(os.path.ismount('/')) self.assertFalse(os.path.ismount('//share/foo'))
def test_windows(self): self.fs.os = OSType.WINDOWS path = r'C:\foo\bar' self.assertEqual(path, os.path.join('C:\\', 'foo', 'bar')) self.assertEqual(('C:', r'\foo\bar'), os.path.splitdrive(path)) self.fs.create_file(path) self.assertTrue(os.path.exists(path)) self.assertTrue(os.path.exists(path.upper())) self.assertTrue(os.path.ismount(r'\\share\foo')) self.assertTrue(os.path.ismount(r'C:'))
def test_macos(self): self.fs.os = OSType.MACOS path = '/foo/bar' self.assertEqual(path, os.path.join('/', 'foo', 'bar')) self.assertEqual(('', 'C:/foo/bar'), os.path.splitdrive('C:/foo/bar')) self.fs.create_file(path) self.assertTrue(os.path.exists(path)) self.assertTrue(os.path.exists(path.upper())) self.assertTrue(os.path.ismount('/')) self.assertFalse(os.path.ismount('//share/foo')) self.assertEqual('/', os.sep) self.assertEqual('/', os.path.sep) self.assertEqual(None, os.altsep) self.assertEqual(':', os.pathsep) self.assertEqual('\n', os.linesep) self.assertEqual('/dev/null', os.devnull)
def smallest_r(n , log_2_n): #find smallest r such that order_r(n) > [log_2(n)]**2 #if f and n are not coprime, then SKIP this r. print "Running smallest_r(n , log_2_n).." print "log_2_n is: "+str(log_2_n) #calculate [log_2(n)]**2 log_2_n_squared = pow(log_2_n,2) print "log_2_n_squared is: "+str(log_2_n_squared) #intialise r and order_r_n r = 1 #order_r_n = 1 # ********** what does it mean by ord_r(n) ??? -> pow(n, ord_r(n))=1 ********** ??? # What is the Group G? - Multiplicative Group - (Z/rZ)* #Z_n - denotes set of integers modulo n #F_p denotes finite field with p elements #find smallest r while r <= math.upper(pow(log_2_n,5)): #if order_r_n <> 1: #order_r(n) > 1 - Hence there must be a prime divisor p of n, s.t. order_p(n) > 1 #p > r. (n,r)=1 order_r_n = calc_order(r,n) #exponent_g_n(r, 1, n) ??? if order_r_n <= log_2_n_squared: r = r + 1 elif order_r_n > log_2_n_squared: #check if r and n are coprime if gcd(r,n) == 1: r = r + 1 else: print "r found: "+str(r) status = True return r, status else: print "order_r_n: "+str(order_r_n)+", log_2_n_squared: "+str(log_2_n_squared) if r == 1: status = False return r, status print "r not found!