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

Failing doctest for gettingstarted.md #21

Closed
earnestt1234 opened this issue Oct 22, 2022 · 1 comment
Closed

Failing doctest for gettingstarted.md #21

earnestt1234 opened this issue Oct 22, 2022 · 1 comment

Comments

@earnestt1234
Copy link
Owner

The examples in gettingstarted.md (included on the landing page for API docs) do not pass doctesting, as they are intended to. Full input/output below.

The problems seem to be cases where the order of items served by os.listdir is different than expected. I.e., for the most part the folder structures have the same items, but different orders. I have verified that the testing passes on one machine (Windows) but fails on another (Mac).

Generally, this shouldn't rely on the behavior of os.listidir for returning a particular order. Not sure exactly what to do yet, but here is my brainstorming of a few potential approaches:

  1. Add a sort=True to every call, then output should be reliably identical. The only downside is that this makes the documentation less clean IMO (adds an argument not relevant to the concepts being displayed)
  2. Create a separate script for testing this code. I looked into this briefly, and seems possible but perhaps overly complicated. It also doesn't solve the cases were the actual items included are different (e.g. when the itemlimit is set).
  3. Create an alternative version of this documentation which is doctestable.
  4. Do nothing and accept that this file cannot be doctested, or at least that a certain amount of failures are expected.

I'm most okay with option 4 if there is some improvement of the test suite, following #17.


Input:

$ python -m doctest gettingstarted.md

Output:

**********************************************************************
File "gettingstarted.md", line 18, in gettingstarted.md
Failed example:
    sd.seedir(path)
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─cataclysmic.txt
    ├─scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ │ └─electrophoresis.txt
    │ └─reliquary.pdf
    └─Vogel.txt
Got:
    exampledir/
    ├─scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ │ └─electrophoresis.txt
    │ └─reliquary.pdf
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─cataclysmic.txt
    └─Vogel.txt
**********************************************************************
File "gettingstarted.md", line 51, in gettingstarted.md
Failed example:
    sd.seedir(path, include_folders=['scrooge','paycheck'], exclude_files='reliquary.pdf')
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    ├─scrooge/
    │ ├─light.pdf
    │ └─paycheck/
    │   └─electrophoresis.txt
    └─Vogel.txt
Got:
    exampledir/
    ├─scrooge/
    │ ├─light.pdf
    │ └─paycheck/
    │   └─electrophoresis.txt
    ├─jowly.pdf
    ├─monkish.txt
    └─Vogel.txt
**********************************************************************
File "gettingstarted.md", line 66, in gettingstarted.md
Failed example:
    sd.seedir(path, include_files='.*\.pdf$', regex=True) # all PDFs
Expected:
    exampledir/
    ├─jowly.pdf
    ├─pedantic/
    └─scrooge/
      ├─light.pdf
      ├─paycheck/
      └─reliquary.pdf
Got:
    exampledir/
    ├─scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ └─reliquary.pdf
    ├─jowly.pdf
    └─pedantic/
**********************************************************************
File "gettingstarted.md", line 104, in gettingstarted.md
Failed example:
    sd.seedir(path, depthlimit=1)
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    ├─scrooge/
    └─Vogel.txt
Got:
    exampledir/
    ├─scrooge/
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    └─Vogel.txt
**********************************************************************
File "gettingstarted.md", line 112, in gettingstarted.md
Failed example:
    sd.seedir(path, itemlimit=3)
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    └─pedantic/
      └─cataclysmic.txt
Got:
    exampledir/
    ├─scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ │ └─electrophoresis.txt
    │ └─reliquary.pdf
    ├─jowly.pdf
    └─monkish.txt
**********************************************************************
File "gettingstarted.md", line 126, in gettingstarted.md
Failed example:
    sd.seedir(path, depthlimit=1, beyond='content')
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─0 folder(s), 1 file(s)
    ├─scrooge/
    │ └─1 folder(s), 2 file(s)
    └─Vogel.txt
Got:
    exampledir/
    ├─scrooge/
    │ └─1 folder(s), 2 file(s)
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─0 folder(s), 1 file(s)
    └─Vogel.txt
**********************************************************************
File "gettingstarted.md", line 194, in gettingstarted.md
Failed example:
    sd.seedir(path, style='emoji')
Expected:
    📁 exampledir/
    ├─📄 jowly.pdf
    ├─📄 monkish.txt
    ├─📁 pedantic/
    │ └─📄 cataclysmic.txt
    ├─📁 scrooge/
    │ ├─📄 light.pdf
    │ ├─📁 paycheck/
    │ │ └─📄 electrophoresis.txt
    │ └─📄 reliquary.pdf
    └─📄 Vogel.txt
Got:
    📁 exampledir/
    ├─📁 scrooge/
    │ ├─📄 light.pdf
    │ ├─📁 paycheck/
    │ │ └─📄 electrophoresis.txt
    │ └─📄 reliquary.pdf
    ├─📄 jowly.pdf
    ├─📄 monkish.txt
    ├─📁 pedantic/
    │ └─📄 cataclysmic.txt
    └─📄 Vogel.txt
**********************************************************************
File "gettingstarted.md", line 214, in gettingstarted.md
Failed example:
    sd.seedir(path, style='spaces', indent=4)
Expected:
    exampledir/
        jowly.pdf
        monkish.txt
        pedantic/
            cataclysmic.txt
        scrooge/
            light.pdf
            paycheck/
                electrophoresis.txt
            reliquary.pdf
        Vogel.txt
Got:
    exampledir/
        scrooge/
            light.pdf
            paycheck/
                electrophoresis.txt
            reliquary.pdf
        jowly.pdf
        monkish.txt
        pedantic/
            cataclysmic.txt
        Vogel.txt
**********************************************************************
File "gettingstarted.md", line 227, in gettingstarted.md
Failed example:
    sd.seedir(path, style='plus', indent=6)
Expected:
    exampledir/
    +-----jowly.pdf
    +-----monkish.txt
    +-----pedantic/
    |     +-----cataclysmic.txt
    +-----scrooge/
    |     +-----light.pdf
    |     +-----paycheck/
    |     |     +-----electrophoresis.txt
    |     +-----reliquary.pdf
    +-----Vogel.txt
Got:
    exampledir/
    +-----scrooge/
    |     +-----light.pdf
    |     +-----paycheck/
    |     |     +-----electrophoresis.txt
    |     +-----reliquary.pdf
    +-----jowly.pdf
    +-----monkish.txt
    +-----pedantic/
    |     +-----cataclysmic.txt
    +-----Vogel.txt
**********************************************************************
File "gettingstarted.md", line 253, in gettingstarted.md
Failed example:
    sd.seedir(path, space='  ', extend='||', split='-}', final='\\\\', folderstart=' ', filestart=' ', folderend='%')
Expected:
    exampledir%
    -} jowly.pdf
    -} monkish.txt
    -} pedantic%
    ||\\ cataclysmic.txt
    -} scrooge%
    ||-} light.pdf
    ||-} paycheck%
    ||||\\ electrophoresis.txt
    ||\\ reliquary.pdf
    \\ Vogel.txt
Got:
    exampledir%
    -} scrooge%
    ||-} light.pdf
    ||-} paycheck%
    ||||\\ electrophoresis.txt
    ||\\ reliquary.pdf
    -} jowly.pdf
    -} monkish.txt
    -} pedantic%
    ||\\ cataclysmic.txt
    \\ Vogel.txt
**********************************************************************
File "gettingstarted.md", line 271, in gettingstarted.md
Failed example:
    sd.seedir(path, uniform='----', anystart='>')
Expected:
    >exampledir/
    ---->jowly.pdf
    ---->monkish.txt
    ---->pedantic/
    -------->cataclysmic.txt
    ---->scrooge/
    -------->light.pdf
    -------->paycheck/
    ------------>electrophoresis.txt
    -------->reliquary.pdf
    ---->Vogel.txt
Got:
    >exampledir/
    ---->scrooge/
    -------->light.pdf
    -------->paycheck/
    ------------>electrophoresis.txt
    -------->reliquary.pdf
    ---->jowly.pdf
    ---->monkish.txt
    ---->pedantic/
    -------->cataclysmic.txt
    ---->Vogel.txt
**********************************************************************
File "gettingstarted.md", line 310, in gettingstarted.md
Failed example:
    sd.seedir(path, formatter=my_style)
Expected:
    exampledir/
    ├─jowly.pdf
    ├─✏️monkish.txt
    ├─pedantic/
    │ └─✏️cataclysmic.txt
    ├─👉scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ │ └─✏️electrophoresis.txt
    │ └─reliquary.pdf
    └─✏️Vogel.txt
Got:
    exampledir/
    ├─👉scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ │ └─✏️electrophoresis.txt
    │ └─reliquary.pdf
    ├─jowly.pdf
    ├─✏️monkish.txt
    ├─pedantic/
    │ └─✏️cataclysmic.txt
    └─✏️Vogel.txt
**********************************************************************
File "gettingstarted.md", line 334, in gettingstarted.md
Failed example:
    sd.seedir(path, formatter=no_root_files)
Expected:
    exampledir/
    ├─pedantic/
    │ └─cataclysmic.txt
    └─scrooge/
      ├─light.pdf
      ├─paycheck/
      │ └─electrophoresis.txt
      └─reliquary.pdf
Got:
    exampledir/
    ├─scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ │ └─electrophoresis.txt
    │ └─reliquary.pdf
    └─pedantic/
      └─cataclysmic.txt
**********************************************************************
File "gettingstarted.md", line 363, in gettingstarted.md
Failed example:
    sd.seedir(path, formatter=mark)
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─✔️ cataclysmic.txt
    ├─scrooge/
    │ ├─❌ light.pdf
    │ ├─❌ paycheck/
    │ │ └─electrophoresis.txt
    │ └─❌ reliquary.pdf
    └─Vogel.txt
Got:
    exampledir/
    ├─scrooge/
    │ ├─❌ light.pdf
    │ ├─❌ paycheck/
    │ │ └─electrophoresis.txt
    │ └─❌ reliquary.pdf
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─✔️ cataclysmic.txt
    └─Vogel.txt
**********************************************************************
File "gettingstarted.md", line 377, in gettingstarted.md
Failed example:
    sd.seedir(path, formatter=mark, sticky_formatter=True)
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─✔️ cataclysmic.txt
    ├─scrooge/
    │ ├─❌ light.pdf
    │ ├─❌ paycheck/
    │ │ └─❌ electrophoresis.txt
    │ └─❌ reliquary.pdf
    └─Vogel.txt
Got:
    exampledir/
    ├─scrooge/
    │ ├─❌ light.pdf
    │ ├─❌ paycheck/
    │ │ └─❌ electrophoresis.txt
    │ └─❌ reliquary.pdf
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─✔️ cataclysmic.txt
    └─Vogel.txt
**********************************************************************
File "gettingstarted.md", line 403, in gettingstarted.md
Failed example:
    f.seedir(formatter=formatter)
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    | +-cataclysmic.txt
    ├─scrooge/
    | +-light.pdf
    | +-paycheck/
    | | +-electrophoresis.txt
    | +-reliquary.pdf
    └─Vogel.txt
Got:
    exampledir/
    ├─scrooge/
    | +-light.pdf
    | +-paycheck/
    | | +-electrophoresis.txt
    | +-reliquary.pdf
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    | +-cataclysmic.txt
    └─Vogel.txt
**********************************************************************
File "gettingstarted.md", line 520, in gettingstarted.md
Failed example:
    f.seedir()
Expected:
    exampledir/
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─cataclysmic.txt
    ├─scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ │ └─electrophoresis.txt
    │ └─reliquary.pdf
    └─Vogel.txt
Got:
    exampledir/
    ├─scrooge/
    │ ├─light.pdf
    │ ├─paycheck/
    │ │ └─electrophoresis.txt
    │ └─reliquary.pdf
    ├─jowly.pdf
    ├─monkish.txt
    ├─pedantic/
    │ └─cataclysmic.txt
    └─Vogel.txt
**********************************************************************
1 items had failures:
  17 of  65 in gettingstarted.md
***Test Failed*** 17 failures.
@earnestt1234
Copy link
Owner Author

Accepting this as not a big deal for now

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

1 participant