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

test_api: Normalize file name and path #608

Merged
merged 1 commit into from
Nov 22, 2021

Conversation

toonn
Copy link
Contributor

@toonn toonn commented Nov 10, 2021

test_list_notebooks was failing on file systems with unicode
normalization different from the encoding used in the strings. In particular on macOS with HFS+ I got failures for four of the file names. This is because HFS+ uses normalization form D while normalization form C is more commonly used, especially on Linux.

By normalizing the name and path read from disk to NFC we avoid the mismatch as long as no NFD strings are added to the dirs tuples. There are other unicode normal forms and normalization is not necessarily invertible so this is not a perfect solution.

I can think of two alternative solutions:

  1. Refrain from using any unicode symbols that have different representations in the various normal forms.
  2. Write temporary files to disk somewhere, the read back the paths and filenames and use those instead of the original strings in the test.

test_list_notebooks was failing on file systems with unicode
normalization different from the encoding used in the strings. In
particular on macOS with HFS+ I got failures for four of the file names.
This is because HFS+ uses normalization form D while normalization form
C is more commonly used, especially on Linux.

By normalizing the name and path read from disk to NFC we avoid the
mismatch as long as no NFD strings are added to the `dirs` tuples.
There are other unicode normal forms and normalization is not
necessarily invertible so this is not a perfect solution.

I can think of two alternative solutions:

1. Refrain from using any unicode symbols that have different
   representations in the various normal forms.
2. Write temporary files to disk somewhere, the read back the paths and
   filenames and use those instead of the original strings in the test.
@welcome
Copy link

welcome bot commented Nov 10, 2021

Thanks for submitting your first pull request! You are awesome! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please make sure you followed the pull request template, as this will help us review your contribution more quickly.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also a intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

@toonn
Copy link
Contributor Author

toonn commented Nov 10, 2021

(There was no PR template to follow.)

@codecov-commenter
Copy link

codecov-commenter commented Nov 10, 2021

Codecov Report

Merging #608 (345e26c) into master (a1b013e) will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #608      +/-   ##
==========================================
- Coverage   77.41%   77.36%   -0.06%     
==========================================
  Files         110      110              
  Lines       10252    10253       +1     
  Branches     1259     1259              
==========================================
- Hits         7937     7932       -5     
- Misses       1918     1926       +8     
+ Partials      397      395       -2     
Impacted Files Coverage Δ
jupyter_server/tests/services/contents/test_api.py 99.76% <100.00%> (+<0.01%) ⬆️
jupyter_server/services/kernels/kernelmanager.py 79.79% <0.00%> (-2.06%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1b013e...345e26c. Read the comment docs.

Copy link
Contributor

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@blink1073 blink1073 added this to the 1.11 milestone Nov 22, 2021
@blink1073 blink1073 merged commit c5c515b into jupyter-server:master Nov 22, 2021
@welcome
Copy link

welcome bot commented Nov 22, 2021

Congrats on your first merged pull request in this project! 🎉
congrats
Thank you for contributing, we are very proud of you! ❤️

@blink1073 blink1073 modified the milestones: 1.11, 1.12 Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants