~jelmer/ubuntu/maverick/bzr/proposed-2.2.3

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_outside_wt.py

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2006-11-08 01:28:55 UTC
  • mfrom: (1.1.15 upstream) (3.1.14 edgy)
  • Revision ID: james.westby@ubuntu.com-20061108012855-faugrhqdxr3cuu9o
Tags: 0.11-1.1
* Non-maintainer upload.
* In test_osutils.py, sort what we get from os.listdir() before checking it;
  the OS can give back directory entries in whatever order it likes, and
  this shouldn't break the tests. Fixes intermittent test failures and
  FTBFS. (Closes: #395203)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2006 by Canonical Ltd
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# This program is free software; you can redistribute it and/or modify
 
5
# it under the terms of the GNU General Public License as published by
 
6
# the Free Software Foundation; either version 2 of the License, or
 
7
# (at your option) any later version.
 
8
#
 
9
# This program is distributed in the hope that it will be useful,
 
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
# GNU General Public License for more details.
 
13
#
 
14
# You should have received a copy of the GNU General Public License
 
15
# along with this program; if not, write to the Free Software
 
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
17
 
 
18
 
 
19
"""Black-box tests for running bzr outside of a working tree."""
 
20
 
 
21
import os
 
22
import tempfile
 
23
 
 
24
from bzrlib.tests import ChrootedTestCase
 
25
from bzrlib.osutils import getcwd
 
26
import bzrlib.urlutils as urlutils
 
27
 
 
28
 
 
29
class TestOutsideWT(ChrootedTestCase):
 
30
    """Test that bzr gives proper errors outside of a working tree."""
 
31
 
 
32
    def test_cwd_log(self):
 
33
        os.chdir(tempfile.mkdtemp())
 
34
        out, err = self.run_bzr('log', retcode=3)
 
35
        self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
 
36
                         err)
 
37
 
 
38
    def test_url_log(self):
 
39
        url = self.get_readonly_url() + 'subdir/'
 
40
        out, err = self.run_bzr('log', 
 
41
                                url, retcode=3)
 
42
        self.assertEqual(u'bzr: ERROR: Not a branch:'
 
43
                         u' %s\n' % url, err)
 
44
 
 
45
    def test_diff_ouside_tree(self):
 
46
        os.chdir(tempfile.mkdtemp())
 
47
        self.run_bzr_captured(['init', 'branch1'])
 
48
        self.run_bzr_captured(['commit', '-m', 'nothing', 
 
49
                               '--unchanged', 'branch1'])
 
50
        self.run_bzr_captured(['commit', '-m', 'nothing', 
 
51
                               '--unchanged', 'branch1'])
 
52
        # -r X..Y
 
53
        out, err = self.run_bzr_captured(['diff', 
 
54
                                          '-r', 'revno:2:branch2..revno:1'],
 
55
                                         retcode=3)
 
56
        self.assertEquals('', out)
 
57
        self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
 
58
                         err)
 
59
        # -r X
 
60
        out, err = self.run_bzr_captured(['diff', '-r', 'revno:2:branch2'],
 
61
                                         retcode=3)
 
62
        self.assertEquals('', out)
 
63
        self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
 
64
                         err)
 
65
        # -r X..
 
66
        out, err = self.run_bzr_captured(['diff', '-r', 'revno:2:branch2..'],
 
67
                                         retcode=3)
 
68
        self.assertEquals('', out)
 
69
        self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
 
70
                         err)
 
71
        # no -r at all.
 
72
        out, err = self.run_bzr_captured(['diff'],
 
73
                                         retcode=3)
 
74
        self.assertEquals('', out)
 
75
        self.assertEqual(u'bzr: ERROR: Not a branch: %s/\n' % (getcwd(),),
 
76
                         err)
 
77
        
 
78