@@ -573,7 +573,11 @@ def bin_dir(self):
573573
574574    @property  
575575    def  logs_dir (self ):
576-         path  =  os .path .join (self .base_dir , LOGS_DIR )
576+         assert  self ._os_ops  is  not None 
577+         assert  isinstance (self ._os_ops , OsOperations )
578+ 
579+         path  =  self ._os_ops .build_path (self .base_dir , LOGS_DIR )
580+         assert  type (path ) ==  str   # noqa: E721 
577581
578582        # NOTE: it's safe to create a new dir 
579583        if  not  self .os_ops .path_exists (path ):
@@ -583,16 +587,31 @@ def logs_dir(self):
583587
584588    @property  
585589    def  data_dir (self ):
590+         assert  self ._os_ops  is  not None 
591+         assert  isinstance (self ._os_ops , OsOperations )
592+ 
586593        # NOTE: we can't run initdb without user's args 
587-         return  os .path .join (self .base_dir , DATA_DIR )
594+         path  =  self ._os_ops .build_path (self .base_dir , DATA_DIR )
595+         assert  type (path ) ==  str   # noqa: E721 
596+         return  path 
588597
589598    @property  
590599    def  utils_log_file (self ):
591-         return  os .path .join (self .logs_dir , UTILS_LOG_FILE )
600+         assert  self ._os_ops  is  not None 
601+         assert  isinstance (self ._os_ops , OsOperations )
602+ 
603+         path  =  self ._os_ops .build_path (self .logs_dir , UTILS_LOG_FILE )
604+         assert  type (path ) ==  str   # noqa: E721 
605+         return  path 
592606
593607    @property  
594608    def  pg_log_file (self ):
595-         return  os .path .join (self .logs_dir , PG_LOG_FILE )
609+         assert  self ._os_ops  is  not None 
610+         assert  isinstance (self ._os_ops , OsOperations )
611+ 
612+         path  =  self ._os_ops .build_path (self .logs_dir , PG_LOG_FILE )
613+         assert  type (path ) ==  str   # noqa: E721 
614+         return  path 
596615
597616    @property  
598617    def  version (self ):
@@ -719,7 +738,11 @@ def _create_recovery_conf(self, username, slot=None):
719738        ).format (options_string (** conninfo ))  # yapf: disable 
720739        # Since 12 recovery.conf had disappeared 
721740        if  self .version  >=  PgVer ('12' ):
722-             signal_name  =  os .path .join (self .data_dir , "standby.signal" )
741+             assert  self ._os_ops  is  not None 
742+             assert  isinstance (self ._os_ops , OsOperations )
743+ 
744+             signal_name  =  self ._os_ops .build_path (self .data_dir , "standby.signal" )
745+             assert  type (signal_name ) ==  str   # noqa: E721 
723746            self .os_ops .touch (signal_name )
724747        else :
725748            line  +=  "standby_mode=on\n " 
@@ -768,11 +791,14 @@ def _collect_special_files(self):
768791        result  =  []
769792
770793        # list of important files + last N lines 
794+         assert  self ._os_ops  is  not None 
795+         assert  isinstance (self ._os_ops , OsOperations )
796+ 
771797        files  =  [
772-             (os . path . join (self .data_dir , PG_CONF_FILE ), 0 ),
773-             (os . path . join (self .data_dir , PG_AUTO_CONF_FILE ), 0 ),
774-             (os . path . join (self .data_dir , RECOVERY_CONF_FILE ), 0 ),
775-             (os . path . join (self .data_dir , HBA_CONF_FILE ), 0 ),
798+             (self . _os_ops . build_path (self .data_dir , PG_CONF_FILE ), 0 ),
799+             (self . _os_ops . build_path (self .data_dir , PG_AUTO_CONF_FILE ), 0 ),
800+             (self . _os_ops . build_path (self .data_dir , RECOVERY_CONF_FILE ), 0 ),
801+             (self . _os_ops . build_path (self .data_dir , HBA_CONF_FILE ), 0 ),
776802            (self .pg_log_file , testgres_config .error_log_lines )
777803        ]  # yapf: disable 
778804
@@ -840,8 +866,11 @@ def default_conf(self,
840866            This instance of :class:`.PostgresNode`. 
841867        """ 
842868
843-         postgres_conf  =  os .path .join (self .data_dir , PG_CONF_FILE )
844-         hba_conf  =  os .path .join (self .data_dir , HBA_CONF_FILE )
869+         assert  self ._os_ops  is  not None 
870+         assert  isinstance (self ._os_ops , OsOperations )
871+ 
872+         postgres_conf  =  self ._os_ops .build_path (self .data_dir , PG_CONF_FILE )
873+         hba_conf  =  self ._os_ops .build_path (self .data_dir , HBA_CONF_FILE )
845874
846875        # filter lines in hba file 
847876        # get rid of comments and blank lines 
@@ -956,7 +985,7 @@ def append_conf(self, line='', filename=PG_CONF_FILE, **kwargs):
956985                # format a new config line 
957986                lines .append ('{} = {}' .format (option , value ))
958987
959-         config_name  =  os . path . join (self .data_dir , filename )
988+         config_name  =  self . _os_ops . build_path (self .data_dir , filename )
960989        conf_text  =  '' 
961990        for  line  in  lines :
962991            conf_text  +=  text_type (line ) +  '\n ' 
@@ -2040,8 +2069,11 @@ def set_auto_conf(self, options, config='postgresql.auto.conf', rm_options={}):
20402069            rm_options (set, optional): A set containing the names of the options to remove. 
20412070                                         Defaults to an empty set. 
20422071        """ 
2072+         assert  self ._os_ops  is  not None 
2073+         assert  isinstance (self ._os_ops , OsOperations )
2074+ 
20432075        # parse postgresql.auto.conf 
2044-         path  =  os . path . join (self .data_dir , config )
2076+         path  =  self . os_ops . build_path (self .data_dir , config )
20452077
20462078        lines  =  self .os_ops .readlines (path )
20472079        current_options  =  {}
@@ -2127,8 +2159,11 @@ def upgrade_from(self, old_node, options=None, expect_error=False):
21272159        return  self .os_ops .exec_command (upgrade_command , expect_error = expect_error )
21282160
21292161    def  _get_bin_path (self , filename ):
2162+         assert  self ._os_ops  is  not None 
2163+         assert  isinstance (self ._os_ops , OsOperations )
2164+ 
21302165        if  self .bin_dir :
2131-             bin_path  =  os . path . join (self .bin_dir , filename )
2166+             bin_path  =  self . _os_ops . build_path (self .bin_dir , filename )
21322167        else :
21332168            bin_path  =  get_bin_path2 (self .os_ops , filename )
21342169        return  bin_path 
@@ -2333,7 +2368,7 @@ def __init__(self, test_path=None, nodes_to_cleanup=None, os_ops=None):
23332368            if  os .path .isabs (test_path ):
23342369                self .test_path  =  test_path 
23352370            else :
2336-                 self .test_path  =  os . path . join (os_ops .cwd (), test_path )
2371+                 self .test_path  =  os_ops . build_path (os_ops .cwd (), test_path )
23372372        else :
23382373            self .test_path  =  os_ops .cwd ()
23392374        self .nodes_to_cleanup  =  nodes_to_cleanup  if  nodes_to_cleanup  else  []
@@ -2344,7 +2379,7 @@ def make_empty(
23442379            base_dir = None ,
23452380            port = None ,
23462381            bin_dir = None ):
2347-         real_base_dir  =  os . path . join (self .test_path , base_dir )
2382+         real_base_dir  =  self . os_ops . build_path (self .test_path , base_dir )
23482383        self .os_ops .rmdirs (real_base_dir , ignore_errors = True )
23492384        self .os_ops .makedirs (real_base_dir )
23502385
@@ -2373,7 +2408,7 @@ def make_simple(
23732408            initdb_params = initdb_params , allow_streaming = set_replication )
23742409
23752410        # set major version 
2376-         pg_version_file  =  self .os_ops .read (os . path . join (node .data_dir , 'PG_VERSION' ))
2411+         pg_version_file  =  self .os_ops .read (self . os_ops . build_path (node .data_dir , 'PG_VERSION' ))
23772412        node .major_version_str  =  str (pg_version_file .rstrip ())
23782413        node .major_version  =  float (node .major_version_str )
23792414
0 commit comments