mirror of
https://github.com/openSUSE/osc.git
synced 2025-09-08 05:58:43 +02:00
Fix tests so they don't modify fixtures
This commit is contained in:
@@ -16,15 +16,10 @@ def suite():
|
||||
|
||||
class TestInitPackage(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
# workaround for git because it doesn't allow empty dirs
|
||||
if not os.path.exists(os.path.join(FIXTURES_DIR, 'osctest')):
|
||||
os.mkdir(os.path.join(FIXTURES_DIR, 'osctest'))
|
||||
return FIXTURES_DIR
|
||||
|
||||
def tearDown(self):
|
||||
if os.path.exists(os.path.join(FIXTURES_DIR, 'osctest')):
|
||||
os.rmdir(os.path.join(FIXTURES_DIR, 'osctest'))
|
||||
super().tearDown()
|
||||
def setUp(self):
|
||||
super().setUp(copytree=False)
|
||||
|
||||
def test_simple(self):
|
||||
"""initialize a package dir"""
|
||||
|
@@ -17,15 +17,10 @@ def suite():
|
||||
|
||||
class TestInitProject(OscTestCase):
|
||||
def _get_fixtures_dir(self):
|
||||
# workaround for git because it doesn't allow empty dirs
|
||||
if not os.path.exists(os.path.join(FIXTURES_DIR, 'osctest')):
|
||||
os.mkdir(os.path.join(FIXTURES_DIR, 'osctest'))
|
||||
return FIXTURES_DIR
|
||||
|
||||
def tearDown(self):
|
||||
if os.path.exists(os.path.join(FIXTURES_DIR, 'osctest')):
|
||||
os.rmdir(os.path.join(FIXTURES_DIR, 'osctest'))
|
||||
super().tearDown()
|
||||
def setUp(self):
|
||||
super().setUp(copytree=False)
|
||||
|
||||
def test_simple(self):
|
||||
"""initialize a project dir"""
|
||||
|
@@ -1,6 +1,8 @@
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
import osc.commandline
|
||||
@@ -50,6 +52,18 @@ def suite():
|
||||
class TestProjectDiff(OscTestCase):
|
||||
diff_hdr = 'Index: %s\n==================================================================='
|
||||
|
||||
def setUp(self, copytree=True):
|
||||
super().setUp(copytree=copytree)
|
||||
self.tmpdir_fixtures = tempfile.mkdtemp(prefix='osc_test')
|
||||
shutil.copytree(self._get_fixtures_dir(), os.path.join(self.tmpdir_fixtures, "fixtures"))
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
shutil.rmtree(self.tmpdir_fixtures)
|
||||
except:
|
||||
pass
|
||||
super().tearDown()
|
||||
|
||||
def _get_fixtures_dir(self):
|
||||
return FIXTURES_DIR
|
||||
|
||||
@@ -85,10 +99,10 @@ identical: only-in-new
|
||||
os.chdir('/tmp')
|
||||
self.assertRaises(osc.oscerr.WrongArgs, runner)
|
||||
|
||||
self._change_to_tmpdir(FIXTURES_DIR, UPSTREAM)
|
||||
self._change_to_tmpdir(self.tmpdir_fixtures, "fixtures", UPSTREAM)
|
||||
self.assertRaises(osc.oscerr.WrongArgs, runner)
|
||||
|
||||
self._change_to_tmpdir(FIXTURES_DIR, BRANCH)
|
||||
self._change_to_tmpdir(self.tmpdir_fixtures, "fixtures", BRANCH)
|
||||
out = self._run_prdiff()
|
||||
self.assertEqualMultiline(out, exp)
|
||||
|
||||
|
Reference in New Issue
Block a user