Patchwork [hglib] tests: add test for log() method errors

login
register
mail settings
Submitter Alexander Plavin
Date April 27, 2013, 12:50 p.m.
Message ID <0584acb30b9d7d7831cf.1367067041@debian-alexander.dolgopa>
Download mbox | patch
Permalink /patch/1490/
State Changes Requested
Headers show

Comments

Alexander Plavin - April 27, 2013, 12:50 p.m.
# HG changeset patch
# User Alexander Plavin <me@aplavin.ru>
# Date 1367066976 -14400
# Node ID 0584acb30b9d7d7831cf4d74c116539c7ff9768e
# Parent  c635e6e7054f2600d36343eaa1770cb36549382a
tests: add test for log() method errors

Add test to ensure that log() raises an error when unknow revision specified.
As hg log behavior with empty repo changed recently,
two variants are allowed in test.
Augie Fackler - July 26, 2013, 12:37 a.m.
On Apr 27, 2013, at 5:50 AM, Alexander Plavin <me@aplavin.ru> wrote:

> # HG changeset patch
> # User Alexander Plavin <me@aplavin.ru>
> # Date 1367066976 -14400
> # Node ID 0584acb30b9d7d7831cf4d74c116539c7ff9768e
> # Parent  c635e6e7054f2600d36343eaa1770cb36549382a
> tests: add test for log() method errors
> 
> Add test to ensure that log() raises an error when unknow revision specified.
> As hg log behavior with empty repo changed recently,
> two variants are allowed in test.
> 
> diff -r c635e6e7054f -r 0584acb30b9d tests/test-log.py
> --- a/tests/test-log.py	Fri Apr 26 01:46:08 2013 +0400
> +++ b/tests/test-log.py	Sat Apr 27 16:49:36 2013 +0400
> @@ -1,3 +1,4 @@
> +from hglib.error import CommandError
> import common
> import hglib
> 
> @@ -17,8 +18,11 @@
>         self.assertEquals(revs[0], self.client.log('0')[0])
>         self.assertEquals(self.client.log(), self.client.log(files=['a']))
> 
> -    # def test_errors(self):
> -    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
> -    #     self.append('a', 'a')
> -    #     self.client.commit('first', addremove=True)
> -    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
> \ No newline at end of file
> +    def test_errors(self):
> +        try:
> +            self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
> +        except AssertionError:
> +            self.assertEqual(self.client.log('foo'), [])

Not sure I understand this - in the event of an assertion error, why are we asserting that log() returns nothing? Shouldn't this command either raise or return all the time in this circumstance?

> +        self.append('a', 'a')
> +        self.client.commit('first', addremove=True)
> +        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')


> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Alexander Plavin - July 26, 2013, 7:27 p.m.
2013/7/26 Augie Fackler <raf@durin42.com>:
>
> On Apr 27, 2013, at 5:50 AM, Alexander Plavin <me@aplavin.ru> wrote:
>
>> # HG changeset patch
>> # User Alexander Plavin <me@aplavin.ru>
>> # Date 1367066976 -14400
>> # Node ID 0584acb30b9d7d7831cf4d74c116539c7ff9768e
>> # Parent  c635e6e7054f2600d36343eaa1770cb36549382a
>> tests: add test for log() method errors
>>
>> Add test to ensure that log() raises an error when unknow revision specified.
>> As hg log behavior with empty repo changed recently,
>> two variants are allowed in test.
>>
>> diff -r c635e6e7054f -r 0584acb30b9d tests/test-log.py
>> --- a/tests/test-log.py       Fri Apr 26 01:46:08 2013 +0400
>> +++ b/tests/test-log.py       Sat Apr 27 16:49:36 2013 +0400
>> @@ -1,3 +1,4 @@
>> +from hglib.error import CommandError
>> import common
>> import hglib
>>
>> @@ -17,8 +18,11 @@
>>         self.assertEquals(revs[0], self.client.log('0')[0])
>>         self.assertEquals(self.client.log(), self.client.log(files=['a']))
>>
>> -    # def test_errors(self):
>> -    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
>> -    #     self.append('a', 'a')
>> -    #     self.client.commit('first', addremove=True)
>> -    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
>> \ No newline at end of file
>> +    def test_errors(self):
>> +        try:
>> +            self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
>> +        except AssertionError:
>> +            self.assertEqual(self.client.log('foo'), [])
>
> Not sure I understand this - in the event of an assertion error, why are we asserting that log() returns nothing? Shouldn't this command either raise or return all the time in this circumstance?

There was a change in hg behaviour, and here we accept both variants.

>
>> +        self.append('a', 'a')
>> +        self.client.commit('first', addremove=True)
>> +        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
>
>
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>
Augie Fackler - Aug. 2, 2013, 7:39 p.m.
Got it. Looks reasonable to me. Matt?

On Jul 26, 2013, at 3:27 PM, Alexander Plavin <me@aplavin.ru> wrote:

> 2013/7/26 Augie Fackler <raf@durin42.com>:
>> 
>> On Apr 27, 2013, at 5:50 AM, Alexander Plavin <me@aplavin.ru> wrote:
>> 
>>> # HG changeset patch
>>> # User Alexander Plavin <me@aplavin.ru>
>>> # Date 1367066976 -14400
>>> # Node ID 0584acb30b9d7d7831cf4d74c116539c7ff9768e
>>> # Parent  c635e6e7054f2600d36343eaa1770cb36549382a
>>> tests: add test for log() method errors
>>> 
>>> Add test to ensure that log() raises an error when unknow revision specified.
>>> As hg log behavior with empty repo changed recently,
>>> two variants are allowed in test.
>>> 
>>> diff -r c635e6e7054f -r 0584acb30b9d tests/test-log.py
>>> --- a/tests/test-log.py       Fri Apr 26 01:46:08 2013 +0400
>>> +++ b/tests/test-log.py       Sat Apr 27 16:49:36 2013 +0400
>>> @@ -1,3 +1,4 @@
>>> +from hglib.error import CommandError
>>> import common
>>> import hglib
>>> 
>>> @@ -17,8 +18,11 @@
>>>        self.assertEquals(revs[0], self.client.log('0')[0])
>>>        self.assertEquals(self.client.log(), self.client.log(files=['a']))
>>> 
>>> -    # def test_errors(self):
>>> -    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
>>> -    #     self.append('a', 'a')
>>> -    #     self.client.commit('first', addremove=True)
>>> -    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
>>> \ No newline at end of file
>>> +    def test_errors(self):
>>> +        try:
>>> +            self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
>>> +        except AssertionError:
>>> +            self.assertEqual(self.client.log('foo'), [])
>> 
>> Not sure I understand this - in the event of an assertion error, why are we asserting that log() returns nothing? Shouldn't this command either raise or return all the time in this circumstance?
> 
> There was a change in hg behaviour, and here we accept both variants.
> 
>> 
>>> +        self.append('a', 'a')
>>> +        self.client.commit('first', addremove=True)
>>> +        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
>> 
>> 
>>> _______________________________________________
>>> Mercurial-devel mailing list
>>> Mercurial-devel@selenic.com
>>> http://selenic.com/mailman/listinfo/mercurial-devel
>>
Matt Mackall - Aug. 9, 2013, 10:02 p.m.
On Fri, 2013-08-02 at 15:39 -0400, Augie Fackler wrote:
> Got it. Looks reasonable to me. Matt?

I guess?

> On Jul 26, 2013, at 3:27 PM, Alexander Plavin <me@aplavin.ru> wrote:
> 
> > 2013/7/26 Augie Fackler <raf@durin42.com>:
> >> 
> >> On Apr 27, 2013, at 5:50 AM, Alexander Plavin <me@aplavin.ru> wrote:
> >> 
> >>> # HG changeset patch
> >>> # User Alexander Plavin <me@aplavin.ru>
> >>> # Date 1367066976 -14400
> >>> # Node ID 0584acb30b9d7d7831cf4d74c116539c7ff9768e
> >>> # Parent  c635e6e7054f2600d36343eaa1770cb36549382a
> >>> tests: add test for log() method errors
> >>> 
> >>> Add test to ensure that log() raises an error when unknow revision specified.
> >>> As hg log behavior with empty repo changed recently,
> >>> two variants are allowed in test.
> >>> 
> >>> diff -r c635e6e7054f -r 0584acb30b9d tests/test-log.py
> >>> --- a/tests/test-log.py       Fri Apr 26 01:46:08 2013 +0400
> >>> +++ b/tests/test-log.py       Sat Apr 27 16:49:36 2013 +0400
> >>> @@ -1,3 +1,4 @@
> >>> +from hglib.error import CommandError
> >>> import common
> >>> import hglib
> >>> 
> >>> @@ -17,8 +18,11 @@
> >>>        self.assertEquals(revs[0], self.client.log('0')[0])
> >>>        self.assertEquals(self.client.log(), self.client.log(files=['a']))
> >>> 
> >>> -    # def test_errors(self):
> >>> -    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
> >>> -    #     self.append('a', 'a')
> >>> -    #     self.client.commit('first', addremove=True)
> >>> -    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
> >>> \ No newline at end of file
> >>> +    def test_errors(self):
> >>> +        try:
> >>> +            self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
> >>> +        except AssertionError:
> >>> +            self.assertEqual(self.client.log('foo'), [])
> >> 
> >> Not sure I understand this - in the event of an assertion error, why are we asserting that log() returns nothing? Shouldn't this command either raise or return all the time in this circumstance?
> > 
> > There was a change in hg behaviour, and here we accept both variants.
> > 
> >> 
> >>> +        self.append('a', 'a')
> >>> +        self.client.commit('first', addremove=True)
> >>> +        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
> >> 
> >> 
> >>> _______________________________________________
> >>> Mercurial-devel mailing list
> >>> Mercurial-devel@selenic.com
> >>> http://selenic.com/mailman/listinfo/mercurial-devel
> >>

Patch

diff -r c635e6e7054f -r 0584acb30b9d tests/test-log.py
--- a/tests/test-log.py	Fri Apr 26 01:46:08 2013 +0400
+++ b/tests/test-log.py	Sat Apr 27 16:49:36 2013 +0400
@@ -1,3 +1,4 @@ 
+from hglib.error import CommandError
 import common
 import hglib
 
@@ -17,8 +18,11 @@ 
         self.assertEquals(revs[0], self.client.log('0')[0])
         self.assertEquals(self.client.log(), self.client.log(files=['a']))
 
-    # def test_errors(self):
-    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
-    #     self.append('a', 'a')
-    #     self.client.commit('first', addremove=True)
-    #     self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
\ No newline at end of file
+    def test_errors(self):
+        try:
+            self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
+        except AssertionError:
+            self.assertEqual(self.client.log('foo'), [])
+        self.append('a', 'a')
+        self.client.commit('first', addremove=True)
+        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')