Merge ~nacc/git-ubuntu:test_fixtures-chdir into git-ubuntu:master

Proposed by Nish Aravamudan
Status: Merged
Merged at revision: d28be11e47cbbb9125c792c0ea5bf0891cf813b7
Proposed branch: ~nacc/git-ubuntu:test_fixtures-chdir
Merge into: git-ubuntu:master
Diff against target: 45 lines (+23/-3)
1 file modified
gitubuntu/test_fixtures.py (+23/-3)
Reviewer Review Type Date Requested Status
Andreas Hasenack Approve
Server Team CI bot continuous-integration Approve
Review via email: mp+342953@code.launchpad.net

Commit message

Make jenkins happy.

To post a comment you must log in.
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Just a typo fix inline, +1

That being said, I was expecting to see some chdir calls being dropped, since the directory is changed in the fixture now. Or is this for tests yet to be written?

review: Approve
Revision history for this message
Nish Aravamudan (nacc) wrote :

On Tue, Apr 10, 2018 at 11:08 AM, Andreas Hasenack
<email address hidden> wrote:
> Review: Approve
>
> Just a typo fix inline, +1

Will fix.

> That being said, I was expecting to see some chdir calls being dropped, since the directory is changed in the fixture now. Or is this for tests yet to be written?

Nothing is actually testing the importer itself yet, which is what is
sensitive to the env like this. So yeah, for future tests.

>
> Diff comments:
>
>> diff --git a/gitubuntu/test_fixtures.py b/gitubuntu/test_fixtures.py
>> index de4cf7c..1312133 100644
>> --- a/gitubuntu/test_fixtures.py
>> +++ b/gitubuntu/test_fixtures.py
>> @@ -8,9 +9,28 @@ import gitubuntu.git_repository
>>
>> @pytest.fixture
>> def repo():
>> - """A empty GitUbuntuRepository repository fixture"""
>> + """A empty GitUbuntuRepository repository fixture
>
> s/A/An/
>
>> +
>> + The GitUbuntuRepository class methods (other than main entry point)
>> + assume they are running with the current work directory set to the
>> + Git repository's filesystem path. Additionally, pristine-tar and
>> + other commands require this to be the case, so chdir in the fixture
>> + itself.
>> + """
>> + try:
>> + oldcwd = os.getcwd()
>> + except OSError:
>> + oldcwd = None
>> +
>> with tempfile.TemporaryDirectory() as path:
>> - yield gitubuntu.git_repository.GitUbuntuRepository(path)
>> + os.chdir(path)
>> + try:
>> + yield gitubuntu.git_repository.GitUbuntuRepository(path)
>> + except:
>> + raise
>> + finally:
>> + if oldcwd:
>> + os.chdir(oldcwd)
>>
>>
>> @pytest.fixture
>
>
> --
> https://code.launchpad.net/~nacc/usd-importer/+git/usd-importer/+merge/342953
> Your team Ubuntu Server Dev import team is subscribed to branch usd-importer:master.
>
> --
> Usd-import-announce mailing list
> <email address hidden>
> Modify settings or unsubscribe at: https://lists.canonical.com/mailman/listinfo/usd-import-announce

Revision history for this message
Server Team CI bot (server-team-bot) wrote :

PASSED: Continuous integration, rev:e9a1cccd6cd9e1666e742e557aff93e23c48c2d9
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/390/
Executed test runs:
    SUCCESS: VM Setup
    SUCCESS: Build
    SUCCESS: Unit Tests
    SUCCESS: Integration Tests
    IN_PROGRESS: Declarative: Post Actions

Click here to trigger a rebuild:
https://jenkins.ubuntu.com/server/job/git-ubuntu-ci/390/rebuild

review: Approve (continuous-integration)
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Thanks for the explanation, +1 again

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/gitubuntu/test_fixtures.py b/gitubuntu/test_fixtures.py
2index de4cf7c..06d24d6 100644
3--- a/gitubuntu/test_fixtures.py
4+++ b/gitubuntu/test_fixtures.py
5@@ -1,3 +1,4 @@
6+import os
7 import tempfile
8
9 import pygit2
10@@ -8,13 +9,32 @@ import gitubuntu.git_repository
11
12 @pytest.fixture
13 def repo():
14- """A empty GitUbuntuRepository repository fixture"""
15+ """An empty GitUbuntuRepository repository fixture
16+
17+ The GitUbuntuRepository class methods (other than main entry point)
18+ assume they are running with the current work directory set to the
19+ Git repository's filesystem path. Additionally, pristine-tar and
20+ other commands require this to be the case, so chdir in the fixture
21+ itself.
22+ """
23+ try:
24+ oldcwd = os.getcwd()
25+ except OSError:
26+ oldcwd = None
27+
28 with tempfile.TemporaryDirectory() as path:
29- yield gitubuntu.git_repository.GitUbuntuRepository(path)
30+ os.chdir(path)
31+ try:
32+ yield gitubuntu.git_repository.GitUbuntuRepository(path)
33+ except:
34+ raise
35+ finally:
36+ if oldcwd:
37+ os.chdir(oldcwd)
38
39
40 @pytest.fixture
41 def pygit2_repo():
42- """A empty pygit2 repository fixture in a temporary directory"""
43+ """An empty pygit2 repository fixture in a temporary directory"""
44 with tempfile.TemporaryDirectory() as tmp_dir:
45 yield pygit2.init_repository(tmp_dir)

Subscribers

People subscribed via source and target branches