1
1
# you need os for unittest to work
2
2
import os
3
- import gc
4
3
import threading
5
4
import unittest
6
- from sys import exit , argv , version_info
5
+ from sys import exit , argv
7
6
import signal
8
7
import subprocess
9
8
import shutil
10
- import six
11
9
import testgres
12
10
import hashlib
13
- import re
14
11
import getpass
15
- import select
16
12
from time import sleep
17
13
import re
18
14
import json
@@ -143,6 +139,7 @@ def __init__(self, message, cmd):
143
139
def __str__ (self ):
144
140
return '\n ERROR: {0}\n CMD: {1}' .format (repr (self .message ), self .cmd )
145
141
142
+
146
143
class PostgresNodeExtended (testgres .PostgresNode ):
147
144
148
145
def __init__ (self , base_dir = None , * args , ** kwargs ):
@@ -227,6 +224,7 @@ def table_checksum(self, table, dbname="postgres"):
227
224
con .close ()
228
225
return sum .hexdigest ()
229
226
227
+
230
228
class ProbackupTest (object ):
231
229
# Class attributes
232
230
enterprise = is_enterprise ()
@@ -238,8 +236,13 @@ def __init__(self, *args, **kwargs):
238
236
self .nodes_to_cleanup = []
239
237
240
238
if isinstance (self , unittest .TestCase ):
241
- self .module_name = self .id ().split ('.' )[1 ]
242
- self .fname = self .id ().split ('.' )[3 ]
239
+ try :
240
+ self .module_name = self .id ().split ('.' )[- 2 ]
241
+ self .fname = self .id ().split ('.' )[- 1 ]
242
+ except IndexError :
243
+ print ("Couldn't get module name and function name from self.id(): `{}`" .format (self .id ()))
244
+ self .module_name = self .module_name if self .module_name else str (self ).split ('(' )[1 ].split ('.' )[1 ]
245
+ self .fname = str (self ).split ('(' )[0 ]
243
246
244
247
if '-v' in argv or '--verbose' in argv :
245
248
self .verbose = True
0 commit comments