From: biao716.wang Date: Tue, 27 Nov 2018 03:39:23 +0000 (+0800) Subject: Fixed preview test error about os.getcwd() X-Git-Tag: submit/devel/20190730.052124^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72a9761739d7db9217a244391db5c58dbb6da500;p=tools%2Fosc.git Fixed preview test error about os.getcwd() once using os.getcwd() commond in the test case, it will report the below error: FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/request_fixtures') OSError: [Errno 2] No such file or directory Find a substitutional method to get current working directory. Change-Id: Ib313f51e8ce9770d67186554e397fb0a82c49fc8 --- diff --git a/tests/test_addfiles.py b/tests/test_addfiles.py index ff44ee3..a9b5f87 100644 --- a/tests/test_addfiles.py +++ b/tests/test_addfiles.py @@ -4,8 +4,8 @@ import os import sys from common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/addfile_fixtures') - +#FIXTURES_DIR = os.path.join(os.getcwd(), 'addfile_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'addfile_fixtures') def suite(): import unittest return unittest.makeSuite(TestAddFiles) diff --git a/tests/test_commit.py b/tests/test_commit.py index dce58bc..2636fca 100644 --- a/tests/test_commit.py +++ b/tests/test_commit.py @@ -5,7 +5,8 @@ import sys import urllib2 from common import GET, PUT, POST, DELETE, OscTestCase from xml.etree import cElementTree as ET -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/commit_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'commit_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'commit_fixtures') def suite(): import unittest diff --git a/tests/test_conf.py b/tests/test_conf.py index de45887..b90f00f 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -3,8 +3,8 @@ from common import OscTestCase import os -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/conf_fixtures') - +#FIXTURES_DIR = os.path.join(os.getcwd(), 'conf_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'conf_fixtures') def suite(): import unittest return unittest.makeSuite(TestConf) diff --git a/tests/test_deletefiles.py b/tests/test_deletefiles.py index ae1bbda..900f35c 100644 --- a/tests/test_deletefiles.py +++ b/tests/test_deletefiles.py @@ -3,7 +3,8 @@ import osc.oscerr import os from common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/deletefile_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'deletefile_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'deletefile_fixtures') def suite(): import unittest diff --git a/tests/test_difffiles.py b/tests/test_difffiles.py index 80697be..6d29050 100644 --- a/tests/test_difffiles.py +++ b/tests/test_difffiles.py @@ -4,8 +4,8 @@ import os import re from common import GET, OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/difffile_fixtures') - +#FIXTURES_DIR = os.path.join(os.getcwd(), 'difffile_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'difffile_fixtures') def suite(): import unittest return unittest.makeSuite(TestDiffFiles) diff --git a/tests/test_init_package.py b/tests/test_init_package.py index 47dfec7..d1a43ef 100644 --- a/tests/test_init_package.py +++ b/tests/test_init_package.py @@ -2,7 +2,8 @@ import osc.core import osc.oscerr import os from common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/init_package_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'init_package_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'init_package_fixtures') def suite(): import unittest diff --git a/tests/test_init_project.py b/tests/test_init_project.py index f91196c..fcaabdc 100644 --- a/tests/test_init_project.py +++ b/tests/test_init_project.py @@ -2,7 +2,9 @@ import osc.core import osc.oscerr import os from common import GET, OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/init_project_fixtures') + +#FIXTURES_DIR = os.path.join(os.getcwd(), 'init_project_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'init_project_fixtures') def suite(): import unittest diff --git a/tests/test_package_status.py b/tests/test_package_status.py index 7b4a71e..7b0e7d3 100644 --- a/tests/test_package_status.py +++ b/tests/test_package_status.py @@ -3,8 +3,8 @@ import osc.oscerr import os from common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/project_package_status_fixtures') - +#FIXTURES_DIR = os.path.join(os.getcwd(), 'project_package_status_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'project_package_status_fixtures') def suite(): import unittest return unittest.makeSuite(TestPackageStatus) diff --git a/tests/test_prdiff.py b/tests/test_prdiff.py index 766271d..13e156a 100644 --- a/tests/test_prdiff.py +++ b/tests/test_prdiff.py @@ -7,7 +7,9 @@ import sys from common import GET, POST, OscTestCase, addExpectedRequest, EXPECTED_REQUESTS -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/prdiff_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'prdiff_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'prdiff_fixtures') + API_URL = 'http://localhost/' UPSTREAM = 'some:project' BRANCH = 'home:user:branches:' + UPSTREAM diff --git a/tests/test_project_status.py b/tests/test_project_status.py index 88118a2..58feae7 100644 --- a/tests/test_project_status.py +++ b/tests/test_project_status.py @@ -3,7 +3,8 @@ import osc.oscerr import os from common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/project_package_status_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'project_package_status_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'project_package_status_fixtures') def suite(): import unittest diff --git a/tests/test_repairwc.py b/tests/test_repairwc.py index 6b8fd6e..a7735c0 100644 --- a/tests/test_repairwc.py +++ b/tests/test_repairwc.py @@ -4,7 +4,8 @@ import os import sys from common import GET, PUT, POST, DELETE, OscTestCase from xml.etree import cElementTree as ET -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/repairwc_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'repairwc_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'repairwc_fixtures') def suite(): import unittest diff --git a/tests/test_request.py b/tests/test_request.py index 4334cff..8f06edb 100644 --- a/tests/test_request.py +++ b/tests/test_request.py @@ -3,7 +3,8 @@ import osc.oscerr import os from common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/request_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'request_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'request_fixtures') def suite(): import unittest diff --git a/tests/test_revertfiles.py b/tests/test_revertfiles.py index b62cb51..c68d69a 100644 --- a/tests/test_revertfiles.py +++ b/tests/test_revertfiles.py @@ -3,7 +3,8 @@ import osc.oscerr import os from common import OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/revertfile_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'revertfile_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'revertfile_fixtures') def suite(): import unittest diff --git a/tests/test_setlinkrev.py b/tests/test_setlinkrev.py index 5f2ef65..6d09712 100644 --- a/tests/test_setlinkrev.py +++ b/tests/test_setlinkrev.py @@ -2,7 +2,8 @@ import osc.core import osc.oscerr import os from common import GET, PUT, OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/setlinkrev_fixtures') +#FIXTURES_DIR = os.path.join(os.getcwd(), 'setlinkrev_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'setlinkrev_fixtures') def suite(): import unittest diff --git a/tests/test_update.py b/tests/test_update.py index d58cf48..8a3a0e2 100644 --- a/tests/test_update.py +++ b/tests/test_update.py @@ -3,7 +3,9 @@ import osc.oscerr import os import sys from common import GET, OscTestCase -FIXTURES_DIR = os.path.join(os.getcwd(), 'tests/update_fixtures') + +#FIXTURES_DIR = os.path.join(os.path.dirname(os.getcwd(), 'update_fixtures') +FIXTURES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'update_fixtures') def suite(): import unittest