These are chat archives for coala/coala-bears

17th
Feb 2017
Yash Nisar
@yash-nisar
Feb 17 2017 18:27
While writing the tests for LicenseCheckBear that I'm working on, I'm getting 2 errors :
http://paste.ubuntu.com/24015019/ where http://api.coala.io/en/latest/_modules/coalib/testing/LocalBearTestHelper.html?highlight=check_results mentions List of strings. However when I change it to a string, I get http://paste.ubuntu.com/24015037/ which mentions that The given lines are not a list.. Any workaround to this ?
http://paste.ubuntu.com/24015048/ contains LicenseCheckBearTest.py
Yash Nisar
@yash-nisar
Feb 17 2017 18:42
@Makman2 @jayvdb
Rishav Kumar
@aptrishu
Feb 17 2017 19:05
why are you creating result instance ?
results means result you're expecting after we feed those lines to the bear and execute it..
Yash Nisar
@yash-nisar
Feb 17 2017 19:08
Okay, so should I directly feed the output ?
Rishav Kumar
@aptrishu
Feb 17 2017 19:08
and lines means lines to check.. like the file content that you are going to feed to the bear..
Yash Nisar
@yash-nisar
Feb 17 2017 19:20
I'll try it, nvm @jayvdb @Makman2 :smile:
Rishav Kumar
@aptrishu
Feb 17 2017 20:17
@yash-nisar sorry.. that sounded a bit wrong..
:point_up: February 18, 2017 12:35 AM
let me explain..
like you have written this
self.check_results(
            self.uut,
                '# Copyright (c) 2010-2012 <name of author>'
                '#'
                '# Licensed under the Apache License, Version 2.0 (the "License");'
                '# you may not use this file except in compliance with the License.'
                '# You may obtain a copy of the License at'
                '#'
                '#   http://www.apache.org/licenses/LICENSE-2.0'
                '#'
                '# Unless required by applicable law or agreed to in writing, software'
                '# distributed under the License is distributed on an "AS IS" BASIS,'
                '# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.'
                '# See the License for the specific language governing permissions and'
                '# limitations under the License.',
            [Result.from_values(
                'LicenseCheckBear',
                get_testfile_path('apache_license_2.0.py') +
                ':  Apache (v2.0)',
                load_testfile(get_testfile_path('apache_license_2.0.py')),
            )])
you see the large commented output you have put there..
that is expected output right ?
so in its place you have to put the input file content as a list..
and in the Result.from_values argument
Rishav Kumar
@aptrishu
Feb 17 2017 20:22
write it like..
[Result.from_values(
                'LicenseCheckBear',
               `that large expected output string`,
                file = get_testfile_path('apache_license_2.0.py') +
                ':  Apache (v2.0)'
            )]
Yash Nisar
@yash-nisar
Feb 17 2017 20:32
The large commented thing is my input file
on which I will run the bear
Rishav Kumar
@aptrishu
Feb 17 2017 20:34
cool then swap things.. :)
Look the thing is.. in Result.from_values you'll be sending expected output...
and in lines argument of check_results method you'll be sending input file contents as a list..
Yash Nisar
@yash-nisar
Feb 17 2017 22:38
I'm unable to debug this error http://paste.ubuntu.com/24016364/
I'm not understanding the cause of Assertion error even inspite of the message matching
    def test_copyright(self):  # Fails
        self.check_results(
            self.uut,
            [load_testfile(get_testfile_path('mit_license.py'))],
            [Result.from_values('LicenseCheckBear',
                                '[Copyright: 2008 <name of author>]',
                                file=get_testfile_path(
                                    'mit_license.py'))],
            filename=get_testfile_path('mit_license.py'),
            settings={'licensecheck_copyright': 'True'})
This is the test that is failing