Esempio n. 1
0
    def get_version(self):
        if not self.should_run:
            return Version('0')

        stdout, stderr, rc = sh.run('hg', 'tags')
        tags = [x.split('   ')[0] for x in stdout.splitlines()]
        return max(Version(tag) for tag in tags)
Esempio n. 2
0
    def test_basic_increment_again(self):
        sut = Version('0.0.0')

        sut.increment()
        sut.increment()

        self.assertEquals('0.0.2', sut.content)
Esempio n. 3
0
    def test_with_strings(self):
        b = Version('0.1-foo2')
        a = Version('0.1-foo1')

        self.assertTrue(a < b)
        self.assertTrue(b > a)
        self.assertEqual(b, max(a, b))
        self.assertEqual(b, max(b, a))
Esempio n. 4
0
    def test_basic_comparision_with_two_numbers(self):
        b = Version('0.2')
        a = Version('0.1')

        self.assertTrue(a < b)
        self.assertTrue(b > a)
        self.assertEqual(b, max(a, b))
        self.assertEqual(b, max(b, a))
Esempio n. 5
0
    def test_basic_comparision(self):
        a = Version('0')
        b = Version('1')

        self.assertTrue(a < b)
        self.assertTrue(b > a)
        self.assertEqual(b, max(a, b))
        self.assertEqual(b, max(b, a))
Esempio n. 6
0
    def test_operator_with_number(self):
        sut = Version('0.0.0')

        sut += 1

        self.assertEquals('0.0.1', sut.content)
        self.assertIsInstance(sut, Version)
Esempio n. 7
0
    def test_basic_python_version_increment(self):
        initial = '__version__ = "0.1"'
        expected = '__version__ = "0.2"'
        sut = Version(initial)

        sut += 1

        self.assertEqual(expected, sut.content)
Esempio n. 8
0
    def test_basic_python_version(self):
        initial = '__version__ = "0.1"'
        expected = initial
        sut = Version(initial)

        self.assertEqual(expected, sut.content)
Esempio n. 9
0
    def test_to_string(self):
        sut = Version('0.0.0')

        self.assertEquals('0.0.0', str(sut))
        self.assertEquals('0.0.0', sut.content)
Esempio n. 10
0
    def test_increment_with_string(self):
        sut = Version('0.0.0-example1')

        sut.increment()

        self.assertEquals('0.0.1-example1', sut.content)
Esempio n. 11
0
    def test_bug_1_with_enters(self):
        sut = Version('0.1.1\r\n')

        self.assertEquals('0.1.1\r\n', sut.content)
        self.assertEquals('0.1.1', str(sut))
Esempio n. 12
0
    def test_to_string_with_strings(self):
        sut = Version('0.0.0-example1')

        self.assertEquals('0.0.0-example1', sut.content)
Esempio n. 13
0
    def test_empty_string(self):
        sut = Version('')

        self.assertEquals('0', str(sut))
        self.assertEquals('', sut.content)
Esempio n. 14
0
    def get_version(self):
        if not self.should_run:
            return Version('0')

        stdout, stderr, rc = sh.run('git', 'tag')
        return max(Version(tag) for tag in (stdout or '').split('\n'))
Esempio n. 15
0
 def get_version(self):
     if not self.files:
         return Version('0')
     return max(Version(self._read(x)) for x in self.files)