/usr/lib/python2.7/dist-packages/sphinx_gallery/tests/test_sorting.py is in python-sphinx-gallery 0.1.13-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # -*- coding: utf-8 -*-
r"""
Tests for sorting keys on gallery (sub)sections
===============================================
"""
# Author: Óscar Nájera
# License: 3-clause BSD
from __future__ import division, absolute_import, print_function
import pytest
def test_ExplicitOrder_sorting_key():
"""Test ExplicitOrder"""
from sphinx_gallery.sorting import ExplicitOrder
all_folders = ['e', 'f', 'd', 'c', '01b', 'a']
explicit_folders = ['f', 'd']
key = ExplicitOrder(explicit_folders)
sorted_folders = sorted(["d", "f"], key=key)
assert sorted_folders == explicit_folders
# Test fails on wrong input
with pytest.raises(ValueError) as excinfo:
ExplicitOrder('nope')
excinfo.match("ExplicitOrder sorting key takes a list")
# Test missing folder
with pytest.raises(ValueError) as excinfo:
sorted_folders = sorted(all_folders, key=key)
excinfo.match('If you use an explicit folder ordering')
|