Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'NoneType' object has no attribute 'has_file' #171

Open
dimaqq opened this issue Aug 7, 2023 · 4 comments
Open

'NoneType' object has no attribute 'has_file' #171

dimaqq opened this issue Aug 7, 2023 · 4 comments

Comments

@dimaqq
Copy link

dimaqq commented Aug 7, 2023

I'm trying to diff a couple of files generated by python coverage tool and converted to XML.

I get an exception here:

    383 def file_source(self, filename):
    384     """
    385     Return a list of namedtuple `Line` for each line of code found in the
    386     given file `filename`.
    387 
    388     """
--> 389     if self.cobertura1.has_file(filename) and self.cobertura1.filesystem.has_file(
    390         filename
    391     ):
    392         lines1 = self.cobertura1.source_lines(filename)
    393         line_statuses1 = dict(self.cobertura1.line_statuses(filename))

AttributeError: 'NoneType' object has no attribute 'has_file'

Somehow the 2nd clause, self.cobertura1.filesystem is None.

@aconrad
Copy link
Owner

aconrad commented Aug 18, 2023

Thanks for reporting. Can you provide the command line you used to get this error?

@dimaqq
Copy link
Author

dimaqq commented Aug 19, 2023

Not a command, I tried

delta.generate() == """\

In the end I've worked around it by passing a filesystem smth object to the cobertura constructor.

I guess the readme can be updated

@aconrad
Copy link
Owner

aconrad commented Aug 20, 2023

Ah, I see. I'll take a look at the README this coming week.

@kumarak-deshaw
Copy link

kumarak-deshaw commented Feb 21, 2024

FTR, it works if the cobertura instantiation has filesystem arg

cobertura1 = Cobertura(xml1, filesystem=filesystem_factory(xml1, source_prefix))
cobertura2 = Cobertura(xml2, filesystem=filesystem_factory(xml2, source_prefix))
reporter = HtmlReporterDelta(cobertura1, cobertura2, show_source=True)
reporter.generate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants