← Back to team overview

launchpad-dev team mailing list archive

Re: [Branch ~launchpad-pqm/launchpad/devel] Rev 10012: [r=mwhudson][ui=none] Allow listing sftp directories on

 

Bjorn Tillenius wrote:
> On Wed, Dec 09, 2009 at 09:57:51AM -0500, Aaron Bentley wrote:
>> Bjorn Tillenius wrote:

> Well, reading the code, it looks like it can be either None or not
> exist. How do I know that it can't be None?

By knowing what a stat_result is.

> Also, why do you have this assert as the last check?

Because I added it after the previous assert was passing.

> I'm asking, since
> somehow it feels natural to me to first check the pre-conditions, and
> then make sure the code works, rather then first showing that the code
> works, and then check the pre-conditions. For example, what happens if
> the pre-condition fails? Where is the error reported?

It's not a pre-condition, it's a post-condition.

> Of course, there's
> also the question, do you need to check that that the attribute is
> missing?

Yes.  It would be bad for _format_directory_entries to modify its input.

> What happens if stat_result suddenly would gain that attribute?
> Does _format_directory_entries() start to fail?

No.  The existing tests use posix.stat_result, which has that attribute.
 They pass, so we know that _format_directory_entries works when that
attribute is present.

If MemoryStat started providing st_mtime, then this test would fail, and
we could update the code so that it stopped setting st_mtime to 0.

Aaron



Follow ups

References