Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitacfc3fa

Browse files
authored
Merge pull request#2 from stalkerg/master
PEP8 cleanups
2 parentsa8ae5b6 +76e21ff commitacfc3fa

File tree

2 files changed

+40
-24
lines changed

2 files changed

+40
-24
lines changed

‎testgres/testgres.py

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323

2424
importos
2525
importrandom
26-
importsocket
26+
#import socket
2727
importsubprocess
2828
importpwd
2929
importtempfile
3030
importshutil
3131
importtime
3232
importsix
3333

34-
# Try to use psycopg2 by default. If psycopg2 isn"t available then use
34+
# Try to use psycopg2 by default. If psycopg2 isn"t available then use
3535
# pg8000 which is slower but much more portable because uses only
3636
# pure-Python code
3737
try:
@@ -44,21 +44,28 @@
4444

4545

4646
registered_nodes= []
47-
last_assigned_port=int(random.random()*16384)+49152;
47+
last_assigned_port=int(random.random()*16384)+49152
4848
pg_config_data= {}
4949

5050

51-
"""
52-
Predefined exceptions
53-
"""
54-
classClusterException(Exception):pass
55-
classQueryException(Exception):pass
51+
classClusterException(Exception):
52+
"""
53+
Predefined exceptions
54+
"""
55+
pass
56+
57+
58+
classQueryException(Exception):
59+
"""
60+
Predefined exceptions
61+
"""
62+
pass
5663

5764

58-
"""
59-
Transaction wrapper returned by Node
60-
"""
6165
classNodeConnection(object):
66+
"""
67+
Transaction wrapper returned by Node
68+
"""
6269
def__init__(self,parent_node,dbname):
6370
self.parent_node=parent_node
6471

@@ -78,21 +85,22 @@ def __exit__(self, type, value, tb):
7885
self.connection.close()
7986

8087
defbegin(self,isolation_level=0):
81-
levels= ['read uncommitted',
82-
'read committed',
83-
'repeatable read',
84-
'serializable']
88+
levels= ['read uncommitted',
89+
'read committed',
90+
'repeatable read',
91+
'serializable']
8592

93+
print(type(isolation_level))
8694
# Check if level is int [0..3]
87-
ifisinstance(isolation_level,int)and \
88-
isolation_levelinrange(0,4):
95+
if(isinstance(isolation_level,int)and
96+
isolation_levelinrange(0,4)):
8997

9098
# Replace index with isolation level type
9199
isolation_level=levels[isolation_level]
92100

93101
# Or it might be a string
94-
elifisinstance(isolation_level,str)and \
95-
str.lower(isolation_level)inlevels:
102+
elif(isinstance(isolation_level,six.text_type)and
103+
isolation_level.lower()inlevels):
96104

97105
# Nothing to do here
98106
pass
@@ -148,13 +156,13 @@ def error_filename(self):
148156

149157
@property
150158
defconnstr(self):
151-
return"port=%s"%self.port
159+
return"port=%s"%self.port
152160
# return "port=%s host=%s" % (self.port, self.host)
153161

154162
defget_bin_path(self,filename):
155163
""" Returns full path to an executable """
156164
pg_config=get_config()
157-
ifnot"BINDIR"inpg_config:
165+
if"BINDIR"notinpg_config:
158166
returnfilename
159167
else:
160168
return"%s/%s"% (pg_config.get("BINDIR"),filename)
@@ -403,6 +411,7 @@ def get_username():
403411
""" Returns current user name """
404412
returnpwd.getpwuid(os.getuid())[0]
405413

414+
406415
defget_config():
407416
globalpg_config_data
408417

@@ -422,19 +431,22 @@ def get_config():
422431

423432
returnpg_config_data
424433

434+
425435
defversion_to_num(version):
426436
"""Converts PostgreSQL version to number for easier comparison"""
427437
importre
428438

429439
ifnotversion:
430440
return0
431441
parts=version.split(".")
432-
whilelen(parts)<3:parts.append("0")
442+
whilelen(parts)<3:
443+
parts.append("0")
433444
num=0
434445
forpartinparts:
435446
num=num*100+int(re.sub("[^\d]","",part))
436447
returnnum
437448

449+
438450
defget_new_node(name):
439451
globalregistered_nodes
440452
globallast_assigned_port
@@ -462,12 +474,14 @@ def get_new_node(name):
462474

463475
returnnode
464476

477+
465478
defclean_all():
466479
globalregistered_nodes
467480
fornodeinregistered_nodes:
468481
node.cleanup()
469482
registered_nodes= []
470483

484+
471485
defstop_all():
472486
globalregistered_nodes
473487
fornodeinregistered_nodes:

‎testgres/tests/test_simple.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
importunittest
2-
importtime
3-
fromtestgresimportget_new_node,clean_all,stop_all
2+
# import time
3+
# from testgres import clean_all
4+
fromtestgresimportget_new_node,stop_all
5+
46

57
classSimpleTest(unittest.TestCase):
68

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp