Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package obs-service-tar_scm for 
openSUSE:Factory checked in at 2021-12-31 13:44:22
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/obs-service-tar_scm (Old)
 and      /work/SRC/openSUSE:Factory/.obs-service-tar_scm.new.1896 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "obs-service-tar_scm"

Fri Dec 31 13:44:22 2021 rev:70 rq:943188 version:0.10.29.1634038025.85bfc3f

Changes:
--------
--- /work/SRC/openSUSE:Factory/obs-service-tar_scm/obs-service-tar_scm.changes  
2021-09-26 21:48:13.582744901 +0200
+++ 
/work/SRC/openSUSE:Factory/.obs-service-tar_scm.new.1896/obs-service-tar_scm.changes
        2021-12-31 13:44:29.537267832 +0100
@@ -1,0 +2,12 @@
+Thu Dec 23 09:01:11 UTC 2021 - [email protected]
+
+- Update to version 0.10.29.1634038025.85bfc3f:
+  * fix test cases
+  * fix various linter problems with pylint 2.11.1
+  * disable consider-using-f-string in pylint
+  * added TC for _stash_pop_required
+  * assertTarIsDeeply now more verbose in case of failure
+  * remove tearDown/Trace from testenv.py
+  * fix regression to keep local changes when running in osc
+
+-------------------------------------------------------------------

Old:
----
  obs-service-tar_scm-0.10.28.1632141620.a8837d3.tar.gz

New:
----
  obs-service-tar_scm-0.10.29.1634038025.85bfc3f.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ obs-service-tar_scm.spec ++++++
--- /var/tmp/diff_new_pack.5v1ZKO/_old  2021-12-31 13:44:30.097268310 +0100
+++ /var/tmp/diff_new_pack.5v1ZKO/_new  2021-12-31 13:44:30.101268314 +0100
@@ -119,8 +119,8 @@
 
 %define pkg_name obs-service-tar_scm
 Name:           %{pkg_name}%{nsuffix}
-%define version_unconverted 0.10.28.1632141620.a8837d3
-Version:        0.10.28.1632141620.a8837d3
+%define version_unconverted 0.10.29.1634038025.85bfc3f
+Version:        0.10.29.1634038025.85bfc3f
 Release:        0
 Summary:        An OBS source service: create tar ball from svn/git/hg
 License:        GPL-2.0-or-later

++++++ PKGBUILD ++++++
--- /var/tmp/diff_new_pack.5v1ZKO/_old  2021-12-31 13:44:30.133268341 +0100
+++ /var/tmp/diff_new_pack.5v1ZKO/_new  2021-12-31 13:44:30.137268344 +0100
@@ -1,5 +1,5 @@
 pkgname=obs-service-tar_scm
-pkgver=0.10.28.1632141620.a8837d3
+pkgver=0.10.29.1634038025.85bfc3f
 pkgrel=0
 pkgdesc="Source Service for the OpenSUSE Build Service (OBS)"
 arch=('any')
@@ -9,9 +9,14 @@
 makedepends=('python' 'python-yaml' 'python-dateutil' 'python-lxml' 
'python-mock' 'bzr' 'git' 'mercurial' 'subversion' )
 depends=('python' 'python-yaml' 'python-dateutil' 'python-argparse' 'cpio' 
'git' 'bzr' 'mercurial' 'subversion' )
 source=("obs-service-tar_scm-${pkgver}.tar.gz")
+noextract=("obs-service-tar_scm-${pkgver}.tar.gz")
 provides=('obs-service-tar')
 sha256sums=('SKIP')
 
+prepare() {
+  tar -axf "obs-service-tar_scm-${pkgver}.tar.gz"
+}
+
 package() {
   cd "${srcdir}/${pkgname}-${pkgver}"
   make DESTDIR="${pkgdir}" PREFIX=/usr install

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.5v1ZKO/_old  2021-12-31 13:44:30.173268375 +0100
+++ /var/tmp/diff_new_pack.5v1ZKO/_new  2021-12-31 13:44:30.177268379 +0100
@@ -7,6 +7,6 @@
           <param 
name="changesrevision">9e8b88b088778c44db56781e6a908a0e82e27cf2</param></service>
 <service name="tar_scm">
                 <param 
name="url">git://github.com/openSUSE/obs-service-tar_scm.git</param>
-              <param 
name="changesrevision">a8837d3a97e8eb6640d219514bc21d3dd6be8d3a</param></service></servicedata>
+              <param 
name="changesrevision">85bfc3fabb06212b49a389afb3310bfbf2996913</param></service></servicedata>
 (No newline at EOF)
 

++++++ debian.dsc ++++++
--- /var/tmp/diff_new_pack.5v1ZKO/_old  2021-12-31 13:44:30.193268392 +0100
+++ /var/tmp/diff_new_pack.5v1ZKO/_new  2021-12-31 13:44:30.197268395 +0100
@@ -1,6 +1,6 @@
 Format: 1.0
 Source: obs-service-tar-scm
-Version: 0.10.28.1632141620.a8837d3
+Version: 0.10.29.1634038025.85bfc3f
 Provides: obs-service-obs_scm, obs-service-tar
 Binary: obs-service-tar_scm
 Maintainer: Adrian Schroeter <[email protected]>

++++++ obs-service-tar_scm-0.10.28.1632141620.a8837d3.tar.gz -> 
obs-service-tar_scm-0.10.29.1634038025.85bfc3f.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/.pylintrc 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/.pylintrc
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/.pylintrc        
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/.pylintrc        
2021-10-12 13:27:05.000000000 +0200
@@ -84,7 +84,7 @@
 #       a feature request to improve pylint in this respect:
 #           https://github.com/PyCQA/pylint/issues/246
 
-disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,missing-docstring,old-style-class,bad-whitespace,consider-using-with
+disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,missing-docstring,old-style-class,bad-whitespace,consider-using-with,consider-using-f-string
 
 
 [REPORTS]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/.pylinttestsrc 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/.pylinttestsrc
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/.pylinttestsrc   
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/.pylinttestsrc   
2021-10-12 13:27:05.000000000 +0200
@@ -84,7 +84,7 @@
 #       a feature request to improve pylint in this respect:
 #           https://github.com/PyCQA/pylint/issues/246
 
-disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,missing-docstring,old-style-class,bad-whitespace,duplicate-code,too-many-public-methods,protected-access,too-many-locals,consider-using-with
+disable=import-star-module-level,old-octal-literal,oct-method,print-statement,unpacking-in-except,parameter-unpacking,backtick,old-raise-syntax,old-ne-operator,long-suffix,dict-view-method,dict-iter-method,metaclass-assignment,next-method-called,raising-string,indexing-exception,raw_input-builtin,long-builtin,file-builtin,execfile-builtin,coerce-builtin,cmp-builtin,buffer-builtin,basestring-builtin,apply-builtin,filter-builtin-not-iterating,using-cmp-argument,useless-suppression,range-builtin-not-iterating,suppressed-message,no-absolute-import,old-division,cmp-method,reload-builtin,zip-builtin-not-iterating,intern-builtin,unichr-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,input-builtin,round-builtin,hex-method,nonzero-method,map-builtin-not-iterating,missing-docstring,old-style-class,bad-whitespace,duplicate-code,too-many-public-methods,protected-access,too-many-locals,consider-using-with,c
 onsider-using-f-string
 
 
 [REPORTS]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/TarSCM/cli.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/TarSCM/cli.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/TarSCM/cli.py    
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/TarSCM/cli.py    
2021-10-12 13:27:05.000000000 +0200
@@ -26,7 +26,7 @@
         aloc_tmp, _ = subprocess.Popen(['locale', '-a'],
                                        stdout=subprocess.PIPE,
                                        stderr=subprocess.STDOUT).communicate()
-    aloc = dict()
+    aloc = {}
 
     for tloc in aloc_tmp.split(b'\n'):
         aloc[tloc] = 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/TarSCM/scm/git.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/TarSCM/scm/git.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/TarSCM/scm/git.py        
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/TarSCM/scm/git.py        
2021-10-12 13:27:05.000000000 +0200
@@ -21,6 +21,7 @@
 
 class Git(Scm):
     scm = 'git'
+    _stash_pop_required = False
 
     def _get_scm_cmd(self):
         """Compose a GIT-specific command line using http proxies"""
@@ -94,6 +95,8 @@
         if 'LANG' in os.environ:
             lang_bak = os.environ['LANG']
             os.environ['LANG'] = "C"
+
+        logging.debug("[switch_revision] GIT STASHING")
         stash_text = self.helpers.safe_run(
             self._get_scm_cmd() + ['stash'],
             cwd=self.clone_dir)[1]
@@ -117,11 +120,8 @@
             sys.exit('%s: No such revision' % self.revision)
 
         if stash_text != "No local changes to save\n":
-            logging.debug("[switch_revision] GIT STASHING")
-            self.helpers.run_cmd(
-                self._get_scm_cmd() + ['stash', 'pop'],
-                cwd=self.clone_dir,
-                interactive=True)
+            self._stash_pop_required = [self.get_current_branch(),
+                                        self.get_current_commit()]
 
         if lang_bak:
             os.environ['LANG'] = lang_bak
@@ -318,7 +318,13 @@
     def get_current_commit(self):
         return self.helpers.safe_run(self._get_scm_cmd() + ['rev-parse',
                                                             'HEAD'],
-                                     self.clone_dir)[1]
+                                     self.clone_dir)[1].rstrip()
+
+    def get_current_branch(self):
+        return self.helpers.safe_run(self._get_scm_cmd() + ['rev-parse',
+                                                            '--abbrev-ref',
+                                                            'HEAD'],
+                                     self.clone_dir)[1].rstrip()
 
     def _ref_exists(self, rev):
         rcode, _ = self.helpers.run_cmd(
@@ -405,9 +411,26 @@
             self.helpers.safe_run(
                 cmd, cwd=self.clone_dir, interactive=sys.stdout.isatty())
 
-    # no cleanup is necessary for git
     def cleanup(self):
-        pass
+        logging.debug("Doing cleanup")
+        if self._stash_pop_required:
+            logging.debug("Stash pop required!")
+            branch = self._stash_pop_required[0]
+            commit = self._stash_pop_required[1]
+            self.helpers.safe_run(
+                self._get_scm_cmd() + ['checkout', branch],
+                self.clone_dir)
+
+            self.helpers.safe_run(
+                self._get_scm_cmd() + ['reset', '--hard', commit],
+                self.clone_dir)
+
+            self.helpers.safe_run(
+                self._get_scm_cmd() + ['stash', 'pop'],
+                cwd=self.clone_dir,
+                interactive=True)
+            self._stash_pop_required = False
+        return True
 
     def check_url(self):
         """check if url is a remote url"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/TarSCM/tasks.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/TarSCM/tasks.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/TarSCM/tasks.py  
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/TarSCM/tasks.py  
2021-10-12 13:27:05.000000000 +0200
@@ -67,9 +67,8 @@
 
         if args.appimage:
             # we read the SCM config from appimage.yml
-            filehandle = open('appimage.yml')
-            self.data_map = yaml.safe_load(filehandle)
-            filehandle.close()
+            with open('appimage.yml', encoding='utf-8') as filehandle:
+                self.data_map = yaml.safe_load(filehandle)
             args.use_obs_scm = True
             build_scms = ()
             try:
@@ -88,9 +87,8 @@
         elif args.snapcraft:
             # we read the SCM config from snapcraft.yaml instead
             # getting it via parameters
-            filehandle = open('snapcraft.yaml')
-            self.data_map = yaml.safe_load(filehandle)
-            filehandle.close()
+            with open('snapcraft.yaml', encoding='utf-8') as filehandle:
+                self.data_map = yaml.safe_load(filehandle)
             args.use_obs_scm = True
             # run for each part an own task
             for part in self.data_map['parts'].keys():
@@ -128,7 +126,7 @@
             # we prefix our own here to be sure to not overwrite user files,
             # if he is using us in "disabled" mode
             new_file = args.outdir + '/_service:snapcraft:snapcraft.yaml'
-            with open(new_file, 'w') as outfile:
+            with open(new_file, 'w', encoding='utf-8') as outfile:
                 outfile.write(yaml.dump(self.data_map,
                                         default_flow_style=False))
 
@@ -152,8 +150,8 @@
             return args
 
         # is it a branch request?
-        ofh = open("_branch_request", "r")
-        dat = json.load(ofh)
+        with open("_branch_request", "r", encoding='utf-8') as ofh:
+            dat = json.load(ofh)
         if dat.get('object_kind') == 'merge_request':
             # gitlab merge request
             args.url = dat['project']['http_url']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/archiveobscpiotestcases.py
 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/archiveobscpiotestcases.py
--- 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/archiveobscpiotestcases.py
 2021-09-20 14:40:20.000000000 +0200
+++ 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/archiveobscpiotestcases.py
 2021-10-12 13:27:05.000000000 +0200
@@ -62,7 +62,8 @@
         infofile = os.path.join(outdir, bname + ".obsinfo")
         self.assertTrue(os.path.isfile(cpiofile))
         self.assertTrue(os.path.isfile(infofile))
-        data = yaml.safe_load(open(infofile, 'r'))
+        with open(infofile, 'r', encoding='UTF-8') as fhl:
+            data = yaml.safe_load(fhl)
         self.assertDictEqual(
             data, {
                 'name': bname,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/commontests.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/commontests.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/commontests.py     
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/commontests.py     
2021-10-12 13:27:05.000000000 +0200
@@ -283,7 +283,6 @@
             )
 
             self.scmlogs.nextlog()
-            self.postRun()
 
     def test_switch_revision_and_subdir(self):
         self._switch_revision_and_subdir()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/fixtures.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/fixtures.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/fixtures.py        
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/fixtures.py        
2021-10-12 13:27:05.000000000 +0200
@@ -118,9 +118,8 @@
             newly_created.append(subdir)
 
         for fname in ('a', subdir + '/b'):
-            fhandle = open(fname, 'w')
-            fhandle.write(str(new_rev))
-            fhandle.close()
+            with open(fname, 'w', encoding="UTF-8") as fhn:
+                fhn.write(str(new_rev))
             self.scmlogs.annotate("Wrote %s to %s" % (new_rev, fname))
 
         # we never commit through symlink 'c' but instead see the updated
@@ -156,9 +155,8 @@
 
         new_rev = self.next_commit_rev(wdir)
         fname = 'd'
-        cfh = open(fname, 'w')
-        cfh.write(str(new_rev))
-        cfh.close()
+        with open(fname, 'w', encoding='UTF-8') as cfh:
+            cfh.write(str(new_rev))
         self.scmlogs.annotate("Wrote %s to %s" % (new_rev, fname))
         self.safe_run('add .')
         date = self.get_committer_date()
@@ -167,7 +165,8 @@
         self.scmlogs.annotate("Created 1 commit; now at %s" % (new_rev))
 
     def touch(self, fname, times=None):
-        with open(os.path.join(self.wdir, fname), 'a'):
+        fpath = os.path.join(self.wdir, fname)
+        with open(fpath, 'a', encoding='UTF-8'):
             os.utime(fname, times)
 
     def remove(self, fname):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/gittests.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/gittests.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/gittests.py        
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/gittests.py        
2021-10-12 13:27:05.000000000 +0200
@@ -204,7 +204,9 @@
         dirents = self.assertNumDirents(self.outdir, expected_dirents)
         self.assertTrue('_servicedata' in dirents,
                         '_servicedata in %s' % repr(dirents))
-        sdat = open(os.path.join(self.outdir, '_servicedata')).read()
+        sdf = os.path.join(self.outdir, '_servicedata')
+        with open(sdf, 'r', encoding='UTF-8') as sdatf:
+            sdat = sdatf.read()
         expected = (
             r"\s*<servicedata>"
             r"\s*<service name=\"tar_scm\">"
@@ -295,8 +297,7 @@
 
         # create
         fix.create_repo(r_dir)
-        f_h = open('f1', 'a')
-        f_h.close()
+        fix.touch('f1')
         fix.safe_run('add .')
         fix.safe_run('commit -m "initial commit"')
 
@@ -368,7 +369,7 @@
         repo_path = fix.repo_path
         os.chdir(repo_path)
         os.mkdir("test")
-        with open("test/myfile.txt", 'w') as file:
+        with open("test/myfile.txt", 'w', encoding="UTF-8") as file:
             file.write("just for testing")
         fix.safe_run('add test')
         fix.safe_run('commit -m "added tests"')
@@ -391,16 +392,21 @@
         # git._stash_and_merge() would not be executed
         repo_dir = os.path.join(self.pkgdir, 'repo')
         fix.safe_run('clone %s %s' % (fix.wdir, repo_dir))
+        test_txt = os.path.join(repo_dir, 'test.txt')
+        fix.touch(test_txt)
+        file4 = os.path.join(repo_dir, 'file.4')
+        with open(file4, 'a', encoding='UTF-8') as fh4:
+            fh4.write("just for testing")
 
         # disable cachedirectory (would not be used with osc by default)
         os.environ['CACHEDIRECTORY'] = ""
 
         # enable osc mode
         os.environ['OSC_VERSION'] = "1"
+
         self.tar_scm_std("--revision", '0.0.3', '--version', '0.0.3')
         # reset osc mode
         del os.environ['OSC_VERSION']
-
         # check result
         expected = [
             'repo-0.0.3',
@@ -409,7 +415,13 @@
             'repo-0.0.3/file.1',
             'repo-0.0.3/file.3',
             'repo-0.0.3/subdir',
-            'repo-0.0.3/subdir/b'
+            'repo-0.0.3/subdir/b',
+            'repo-0.0.3/test.txt'
         ]
-        tar = os.path.join(self.test_dir, 'out', 'repo-0.0.3.tar')
+        tar = os.path.join(self.outdir, 'repo-0.0.3.tar')
         self.assertTarIsDeeply(tar, expected)
+        cwd = os.getcwd()
+        os.chdir(repo_dir)
+        status = fix.safe_run('status -s')
+        os.chdir(cwd)
+        self.assertTrue(status[0] == b' M file.4\n?? test.txt\n')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/hgfixtures.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/hgfixtures.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/hgfixtures.py      
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/hgfixtures.py      
2021-10-12 13:27:05.000000000 +0200
@@ -29,7 +29,7 @@
         os.makedirs(self.repo_path)
         os.chdir(self.repo_path)
         self.safe_run('init')
-        with open('.hg/hgrc', 'w') as rcf:
+        with open('.hg/hgrc', 'w', encoding='UTF-8') as rcf:
             rcf.write("[ui]\nusername = %s\n" % self.name_and_email)
 
         self.wdir = self.repo_path
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/scmlogs.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/scmlogs.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/scmlogs.py 
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/scmlogs.py 
2021-10-12 13:27:05.000000000 +0200
@@ -75,16 +75,13 @@
         os.environ['SCM_INVOCATION_LOG'] = self.current_log_path
 
     def annotate(self, msg):
-        log = open(self.current_log_path, 'a')
-        log.write('# ' + msg + "\n")
         print(msg)
-        log.close()
+        with open(self.current_log_path, 'a', encoding="UTF-8") as log:
+            log.write('# ' + msg + "\n")
 
     def read(self):
         if not os.path.exists(self.current_log_path):
             return '<no %s log>' % self.scm
-
-        log = open(self.current_log_path)
-        loglines = log.readlines()
-        log.close()
+        with open(self.current_log_path, 'r', encoding="UTF-8") as log:
+            loglines = log.readlines()
         return loglines
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/svnfixtures.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/svnfixtures.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/svnfixtures.py     
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/svnfixtures.py     
2021-10-12 13:27:05.000000000 +0200
@@ -37,7 +37,7 @@
         quietrun('svnadmin create ' + self.repo_path)
         # allow revprop changes to explicitly set svn:date
         hook = self.repo_path + '/hooks/pre-revprop-change'
-        with open(hook, 'w') as cfh:
+        with open(hook, 'w', encoding='UTF-8') as cfh:
             cfh.write("#!/bin/sh\nexit 0;\n")
 
         sta = os.stat(hook)
@@ -60,7 +60,7 @@
         return new_rev
 
     def get_metadata(self, formatstr):
-        return self.safe_run('log -n1' % formatstr)[0]
+        return self.safe_run("log -n1 %s" % formatstr)[0]
 
     def record_rev(self, *args):
         rev_num = args[0]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/svntests.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/svntests.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/svntests.py        
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/svntests.py        
2021-10-12 13:27:05.000000000 +0200
@@ -56,7 +56,8 @@
         dirents = self.assertNumDirents(self.outdir, expected_dirents)
         self.assertTrue('_servicedata' in dirents,
                         '_servicedata in %s' % repr(dirents))
-        sdat = open(os.path.join(self.outdir, '_servicedata')).read()
+        with open(os.path.join(self.outdir, '_servicedata')) as sdata:
+            sdat = sdata.read()
         expected = (
             r"<servicedata>"
             r"\s*<service name=\"tar_scm\">"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/tartests.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/tartests.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/tartests.py        
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/tartests.py        
2021-10-12 13:27:05.000000000 +0200
@@ -26,14 +26,13 @@
         info = os.path.join(wdir, "test.obsinfo")
         print("INFOFILE: '%s'" % info)
         os.chdir(self.pkgdir)
-        obsinfo = open(info, 'w')
-        obsinfo.write(
-            "name: pkgname\n" +
-            "version: 0.1.1\n" +
-            "mtime: 1476683264\n" +
-            "commit: fea6eb5f43841d57424843c591b6c8791367a9e5\n"
-        )
-        obsinfo.close()
+        with open(info, 'w', encoding='UTF-8') as obsinfo:
+            obsinfo.write(
+                "name: pkgname\n" +
+                "version: 0.1.1\n" +
+                "mtime: 1476683264\n" +
+                "commit: fea6eb5f43841d57424843c591b6c8791367a9e5\n"
+            )
         src_dir = os.path.join(wdir, "pkgname")
         os.mkdir(src_dir)
         self.tar_scm_std()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/tasks.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/tasks.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/tasks.py   
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/tasks.py   
2021-10-12 13:27:05.000000000 +0200
@@ -163,10 +163,9 @@
         tasks.generate_list()
         tasks.finalize()
         self._restore_cwd()
-        scf = open(os.path.join(self.cli.outdir,
-                                '_service:snapcraft:snapcraft.yaml'), 'r')
-        got = scf.read()
-        scf.close()
+        snf = os.path.join(self.cli.outdir,'_service:snapcraft:snapcraft.yaml')
+        with open(snf, 'r', encoding='utf-8') as scf:
+            got = scf.read()
         self.assertEqual(got, expected)
 
     def test_cleanup(self):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/testassertions.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/testassertions.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/testassertions.py  
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/testassertions.py  
2021-10-12 13:27:05.000000000 +0200
@@ -140,11 +140,18 @@
                    self.update_cache_command, should_not_find)
 
     def assertTarIsDeeply(self, tar, expected):
+        if not os.path.isfile(tar):
+            print("File '%s' not found" % tar)
+            return False
         th = tarfile.open(tar)
         got = []
         for mem in th.getmembers():
             got.append(mem.name)
-        self.assertTrue(got == expected)
+        result = got == expected
+        if result == False:
+            print("got: %r" % got)
+            print("expected: %r" % expected)
+        self.assertTrue(result)
 
     def _find(self, logpath, loglines, should_find, should_not_find):
         found = False
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/testenv.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/testenv.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/testenv.py 
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/testenv.py 
2021-10-12 13:27:05.000000000 +0200
@@ -109,46 +109,6 @@
         os.unsetenv('CACHEDIRECTORY')
         os.environ['CACHEDIRECTORY'] = ""
 
-    def tearDown(self):
-        print()
-        print("--v-v-- begin tearDown for %s --v-v--" % self.test_name)
-        self.postRun()
-        print("--^-^-- end   tearDown for %s --^-^--" % self.test_name)
-        print()
-
-    def postRun(self):
-        self.service = {'mode': 'disabled'}
-        if os.path.exists(self.outdir):
-            self.simulate_osc_postrun()
-
-    def simulate_osc_postrun(self):
-        """
-        Simulate osc copying files from temporary --outdir back to
-        package source directory, so our tests can catch any
-        potential side-effects due to the persistent nature of the
-        package source directory.
-        """
-
-        temp_dir = self.outdir
-        pdir = self.pkgdir
-        service = self.service
-
-        # This code was copied straight out of osc/core.py's
-        # Serviceinfo.execute() (and then line-wrapped for PEP8):
-        # --------- 8< --------- 8< --------- 8< --------- 8< ---------
-        if service['mode'] == "disabled"  or \
-           service['mode'] == "trylocal"  or \
-           service['mode'] == "localonly":
-            for filename in os.listdir(temp_dir):
-                shutil.move(os.path.join(temp_dir, filename),
-                            os.path.join(pdir, filename))
-        else:
-            for filename in os.listdir(temp_dir):
-                shutil.move(os.path.join(temp_dir, filename),
-                            os.path.join(pdir,
-                                         "_service::" + filename))
-        # --------- 8< --------- 8< --------- 8< --------- 8< ---------
-
     def tar_scm_std(self, *args, **kwargs):
         return self.tar_scm(self.stdargs(*args), **kwargs)
 
@@ -190,13 +150,7 @@
         succeeded = True
         ret = 0
         try:
-            tracer = trace.Trace(
-                ignoredirs=[sys.prefix, sys.exec_prefix],
-                trace=0,
-                count=0)
-            tracer.runfunc(TarSCM.run)
-            # r = tracer.results()
-            # r.write_results(show_missing=True, coverdir=".")
+            TarSCM.run()
         except SystemExit as exp:
             print("raised system exit %r" % exp)
             if exp.code == 0:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/unittestcases.py 
new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/unittestcases.py
--- old/obs-service-tar_scm-0.10.28.1632141620.a8837d3/tests/unittestcases.py   
2021-09-20 14:40:20.000000000 +0200
+++ new/obs-service-tar_scm-0.10.29.1634038025.85bfc3f/tests/unittestcases.py   
2021-10-12 13:27:05.000000000 +0200
@@ -287,14 +287,13 @@
         print("INFOFILE: '%s'" % info)
 
         # check for slash in name
-        f_h = open(info, 'w')
-        f_h.write(
-            "name: test/test\n" +
-            "version: 0.1.1\n" +
-            "mtime: 1476683264\n" +
-            "commit: fea6eb5f43841d57424843c591b6c8791367a9e5\n"
-        )
-        f_h.close()
+        with open(info, 'w', encoding='UTF-8') as f_h:
+            f_h.write(
+                "name: test/test\n" +
+                "version: 0.1.1\n" +
+                "mtime: 1476683264\n" +
+                "commit: fea6eb5f43841d57424843c591b6c8791367a9e5\n"
+            )
         os.chdir(wdir)
         six.assertRaisesRegex(
             self,
@@ -304,14 +303,13 @@
         )
 
         # check for slash in version
-        f_h = open(info, 'w')
-        f_h.write(
-            "name: test\n" +
-            "version: a/0.1.1\n" +
-            "mtime: 1476683264\n" +
-            "commit: fea6eb5f43841d57424843c591b6c8791367a9e5\n"
-        )
-        f_h.close()
+        with open(info, 'w', encoding='UTF-8') as f_h:
+            f_h.write(
+                "name: test\n" +
+                "version: a/0.1.1\n" +
+                "mtime: 1476683264\n" +
+                "commit: fea6eb5f43841d57424843c591b6c8791367a9e5\n"
+            )
         os.chdir(wdir)
         six.assertRaisesRegex(
             self,
@@ -321,14 +319,13 @@
         )
 
         # check for .. in version
-        f_h = open(info, 'w')
-        f_h.write(
-            "name: test\n" +
-            "version: ..0.1.1\n" +
-            "mtime: 1476683264\n" +
-            "commit: fea6eb5f43841d57424843c591b6c8791367a9e5\n"
-        )
-        f_h.close()
+        with open(info, 'w', encoding='UTF-8') as f_h:
+            f_h.write(
+                "name: test\n" +
+                "version: ..0.1.1\n" +
+                "mtime: 1476683264\n" +
+                "commit: fea6eb5f43841d57424843c591b6c8791367a9e5\n"
+            )
         os.chdir(wdir)
         six.assertRaisesRegex(
             self,

Reply via email to