Roundup Tracker - Issues

Issue 2550956

classification
test case of serve_static_files
Type: Severity: minor
Components: Versions:
process
Status: closed abandoned
:
: : antmail, ber, rouilj
Priority: low :

Created on 2017-10-25 14:05 by antmail, last changed 2019-06-02 00:31 by rouilj.

Messages
msg6043 Author: [hidden] (antmail) Date: 2017-10-25 14:05
Hello,

I  have  a  question about test case failure. Why do test expect relative
path but not absolute?

test.test_cgi.FormTestCase testMethod=testserve_static_files>

    def testserve_static_files(self):
     ...

        # TEMPLATES dir is searched by default. So this file exists.
        # Check the returned values.
        cl.serve_static_file("issue.index.html")
        self.assertEquals(output[0][1], "text/html")
>       self.assertEquals(output[0][3], "_test_cgi_form/html/issue.index.html")
E       AssertionError: '/devel/hibcore/src/test/_test_cgi_form/html/issue.index.html' !=
'_test_cgi_form/html/issue.index.html'

test_cgi.py:1411: AssertionError
_______________________ memorydbDBTest.testQuietJournal ________________________
msg6044 Author: [hidden] (rouilj) Date: 2017-10-26 00:50
Hi Anthony:

In message <489608269.20171025170504@inbox.ru>,
Anthony writes:

>I  have  a  question about test case failure. Why do test expect relative
>path but not absolute?
>
>test.test_cgi.FormTestCase testMethod=testserve_static_files>
>
>    def testserve_static_files(self):
>     ...
>
>        # TEMPLATES dir is searched by default. So this file exists.
>        # Check the returned values.
>        cl.serve_static_file("issue.index.html")
>        self.assertEquals(output[0][1], "text/html")
>>       self.assertEquals(output[0][3], "_test_cgi_form/html/issue.index.html")
>E       AssertionError: '/devel/hibcore/src/test/_test_cgi_form/html/issue.index.html' !=
>'_test_cgi_form/html/issue.index.html'
>
>test_cgi.py:1411: AssertionError

How did you generate this error? Running:

  ./run_tests.py -k testserve_static_files test/test_cgi.py

  $PWD/run_tests.py -k testserve_static_files test/test_cgi.py

  $PWD/roundup/run_tests.py -k testserve_static_files roundup/test/test_cgi.py

and

  ./run_tests.py -k testserve_static_files $PWD/test/test_cgi.py

all work as expected for me. They generate paths relative to the
current working directory where the test directory is generated.

I expect the relative paths to be repeatable while an absolute path
would not repeatable (it would depend on the absolute location of the
directory where the test was run).
msg6062 Author: [hidden] (ber) Date: 2018-02-08 13:28
Hi Anthony,

can you tell us more about this failing test?
See questions by John hin his last message.

Best Regards,
Bernhard
msg6063 Author: [hidden] (antmail) Date: 2018-02-12 15:51
Greetings,

Sorry for the late reply. I suspended the subject because of thinking
that I'm doing something wrong again.

I run test as:
 ./run_tests.py -k testserve_static_files test/test_cgi.py
 and get error:
 AssertionError: '/devel/hibcore/src/_test_cgi_form/html/issue.index.html' != '_test_cgi_form/html/issue.index.html'

 I have slightly different code base so this may be not an issue.
 I  note  the subject  because I guess this is related to parts that I didn't
 touch.  I did look in code and wondering how relative path can be expected here.

 The  serve_static_file  has the following assignments:

 filename = os.path.normpath(os.path.join(p, file))

where p is  self.instance.config['TEMPLATES'] or self.instance.config['STATIC_FILES']

'TEMPLATES'       and      'STATIC_FILES'      are      FilePathOption
(MultiFilePathOption)  object.   Both  options return an absolute path
like this:

 if _val and not os.path.isabs(_val):
   _val = os.path.join(self.config["HOME"], _val)

So I don't understand how 'filename' can be a relative path.

But may be I've touched some code and forget.

> John Rouillard added the comment:

> Hi Anthony:

> In message <489608269.20171025170504@inbox.ru>,
> Anthony writes:

>>I  have  a  question about test case failure. Why do test expect relative
>>path but not absolute?
>>
>>test.test_cgi.FormTestCase testMethod=testserve_static_files>
>>
>>    def testserve_static_files(self):
>>     ...
>>
>>        # TEMPLATES dir is searched by default. So this file exists.
>>        # Check the returned values.
>>        cl.serve_static_file("issue.index.html")
>>        self.assertEquals(output[0][1], "text/html")
>>>       self.assertEquals(output[0][3], "_test_cgi_form/html/issue.index.html")
>>E       AssertionError: '/devel/hibcore/src/test/_test_cgi_form/html/issue.index.html' !=
>>'_test_cgi_form/html/issue.index.html'
>>
>>test_cgi.py:1411: AssertionError

> How did you generate this error? Running:

>   ./run_tests.py -k testserve_static_files test/test_cgi.py

>   $PWD/run_tests.py -k testserve_static_files test/test_cgi.py

>   $PWD/roundup/run_tests.py -k testserve_static_files roundup/test/test_cgi.py

> and

>   ./run_tests.py -k testserve_static_files $PWD/test/test_cgi.py

> all work as expected for me. They generate paths relative to the
> current working directory where the test directory is generated.

> I expect the relative paths to be repeatable while an absolute path
> would not repeatable (it would depend on the absolute location of the
> directory where the test was run).

> ----------
> nosy: +rouilj

> ________________________________________________
> Roundup tracker <issues@roundup-tracker.org>
> <http://issues.roundup-tracker.org/issue2550956>
> ________________________________________________
msg6064 Author: [hidden] (rouilj) Date: 2018-02-19 02:07
Hi Anthony:

In message <1104332833.20180212185115@inbox.ru>,
Anthony writes:
>Sorry for the late reply. I suspended the subject because of thinking
>that I'm doing something wrong again.
>
>I run test as:
> ./run_tests.py -k testserve_static_files test/test_cgi.py
> and get error:
> AssertionError: '/devel/hibcore/src/_test_cgi_form/html/issue.index.html' != '_test_cgi_form/html/issue.index.html'
>
> I have slightly different code base so this may be not an issue.
> I  note  the subject  because I guess this is related to parts that I didn't
> touch.  I did look in code and wondering how relative path can be
> expected here.

I suspect you are not synced to the current tip and your test file is
out of date. Make sure that the changes in 8743b7226dc7 are
incorporated in your test_cgi.py. In my file that is when the
definition of testserve_static_files was last changed.

What does:

 $ hg summary
 parent: 5312:a4fe76fba54a tip
 issue2550957: Duplicate emails (with patch).
 branch: default
 commit: 2 modified, 1 unknown
 update: (current)
 mq:     (empty queue)

show for you?

Your exact command runs fine for me in a directory synced to the
current head release:

 $ ./run_tests.py -k testserve_static_files test/test_cgi.py
 ========================= test session starts ==============================
 platform linux2 -- Python 2.7.6, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
 rootdir: /home/rouilj/develop/roundup.hg, inifile:
 collected 86 items

 test/test_cgi.py .

 =========== 85 tests deselected by '-ktestserve_static_files' ===============
 ================ 1 passed, 85 deselected in 2.45 seconds ====================

What does:

  $ sum test/test_cgi.py
  05397    81

return for you?

Also what version of python are you using?

Have a great week.
--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
msg6065 Author: [hidden] (antmail) Date: 2018-02-21 08:31
Hello, John.

> I suspect you are not synced to the current tip and your test file is
> out of date. Make sure that the changes in 8743b7226dc7 are
> incorporated in your test_cgi.py. In my file that is when the
> definition of testserve_static_files was last changed.

> What does:

>  $ hg summary
>  parent: 5312:a4fe76fba54a tip
>  issue2550957: Duplicate emails (with patch).
>  branch: default
>  commit: 2 modified, 1 unknown
>  update: (current)
>  mq:     (empty queue)

> show for you?
% hg log test/test_cgi.py | grep -B2 -A3 8743b7226dc7
parent:      5474:4d4ab661de4a
parent:      5278:8743b7226dc7
user:        Anthony Pankov
date:        Sun Jul 09 08:17:56 2017 +0300
summary:     Merging revision 5278
--
changeset:   5278:8743b7226dc7
user:        John Rouillard <rouilj@ieee.org>
date:        Tue Apr 11 22:20:13 2017 -0400
summary:     Fix issue with retreiving raw template files using the @@file mechanism.

> Your exact command runs fine for me in a directory synced to the
> current head release:

>  $ ./run_tests.py -k testserve_static_files test/test_cgi.py

This fails for me:
       self.assertEquals(output[0][3], "_test_cgi_form/html/issue.index.html")
E       AssertionError: '/devel/hibcore/src/_test_cgi_form/html/issue.index.html' != '_test_cgi_form/html/issue.index.html'

> What does:

>   $ sum test/test_cgi.py
>   05397    81
> return for you?

The same.

> Also what version of python are you using?
Python 2.7.13

I'm feeling some discomfort to disturb people with problems created by myself.
msg6076 Author: [hidden] (rouilj) Date: 2018-06-01 01:55
Anthony did you ever figure this out?

You said you have a slightly different code base. Could one of your 
changes be to serve_static_file?

-- rouilj
msg6497 Author: [hidden] (rouilj) Date: 2019-06-02 00:31
No response for over a year. No actions to be done on our side. Closing.
History
Date User Action Args
2019-06-02 00:31:53rouiljsetstatus: open -> closed
resolution: abandoned
messages: + msg6497
2018-06-01 01:55:21rouiljsetstatus: new -> open
messages: + msg6076
2018-02-21 08:31:26antmailsetmessages: + msg6065
2018-02-19 02:08:00rouiljsetmessages: + msg6064
2018-02-12 15:51:24antmailsetmessages: + msg6063
2018-02-08 13:28:11bersetpriority: low
nosy: + ber
messages: + msg6062
severity: normal -> minor
2017-10-26 00:50:45rouiljsetnosy: + rouilj
messages: + msg6044
2017-10-25 14:05:08antmailcreate