summaryrefslogtreecommitdiff
path: root/source4/dsdb/tests/python/sort.py
AgeCommit message (Collapse)AuthorFilesLines
2023-08-30s4:dsdb:tests: Remove unused importsJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-28python: remove all 'from __future__ import print_function'Douglas Bagnall1-1/+0
This made Python 2's print behave like Python 3's print(). In some cases, where we had: from __future__ import print_function """Intended module documentation...""" this will have the side effect of making the intended module documentation work as the actual module documentation (i.e. becoming __doc__), because it is once again the first statement in the module. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-10-02python2 reduction: Merge remaining compat code into commonDavid Mulder1-5/+5
The remaining compat code (get_string, get_bytes, cmp) are useful helper routines which we should simply merge into common (especially since there is some duplication here). Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Fri Oct 2 14:49:36 UTC 2020 on sn-devel-184
2020-08-11python compat: remove text_typeDouglas Bagnall1-2/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2020-02-07pytests: heed assertEquals deprecation warning en-masseDouglas Bagnall1-4/+4
TestCase.assertEquals() is an alias for TestCase.assertEqual() and has been deprecated since Python 2.7. When we run our tests with in python developer mode (`PYTHONDEVMODE=1 make test`) we get 580 DeprecationWarnings about this. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2019-09-01Spelling fixes s/recieved/received/Mathieu Parent1-3/+3
Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-12-14PY3: change shebang to python3 in source4/dsdb dirJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-12-14s4/dsdb/tests/python: Restore embed NULL tests for Python3Noel Power1-49/+38
commit: 34ca15fb042e42773854c093ad9f1e67696c90ac changed the test so embedded NULLs were avoided when python3 was used. This was due to the fact the string comparison function 'locale.strcoll' cannot handle embedded NULLs. This commit a) Restores the test data using embedded NULLs which was not used depending on the python runtime version b) Removes the problematic calculation of expected sorting order and instead uses sort order data stored in files. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-14selftest: Convert samba4.ldap.sort.python to planoldpythontestNoel Power1-4/+4
Currently the test only runs fully under python2. As an interim measure while we figure out how to get this to work property under python3 I have converted the test to planoldpythontest so it also can run under python2 Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-10s4/dsdb/tests/python: PY3 allow test samba4.ldap.sort passNoel Power1-8/+14
Adjust test data to remove use of embedded NULLs. We are getting the following exception when running the test under python3 Exception: Exception: Traceback (most recent call last): File "source4/dsdb/tests/python/sort.py", line 181, in setUp key=cmp_to_key_fn(locale.strcoll)) ValueError: embedded null character Looking at the source code for locale.strcoll the lhs & rhs params are processed using 'PyUnicode_AsWideCharString(s, NULL)' Documentation for PyUnicode_AsWideCharString states: "Convert the Unicode object to a wide character string. The output string always ends with a null character. If size is not NULL, write the number of wide characters (excluding the trailing null termination character) into *size. Note that the resulting wchar_t string might contain null characters, which would cause the string to be truncated when used with most C functions. If size is NULL and the wchar_t* string contains null characters a ValueError is raised." Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-10s4/dsdb/tests/python: partial PY3 port for samba4.ldap.sortNoel Power1-9/+12
Test still fails after applying the following fixes a) only decode byte or (py2) str objects b) fix sorted function no longer use cmp func, use compat cmp_to_key_fn instead c) convert ldb.bytes returned from ldb search results d) convert sort_functions.keys() to list so array slicing works Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-25s4/dsdb/pytest/sort: use compat.cmp_fn instead of cmpDouglas Bagnall1-3/+3
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-09-06PEP8: fix E127: continuation line over-indented for visual indentJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E305: expected 2 blank lines after class or function definition, ↵Joe Guo1-0/+1
found 1 Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E301: expected 1 blank line, found 0Joe Guo1-0/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E226: missing whitespace around arithmetic operatorJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E211: whitespace before '('Joe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-23s3/dsdb: convert print func to be py2/py3 compatibleNoel Power1-27/+28
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-02-15dsdb python tests: convert 'except X, e' to 'except X as e'Douglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-03-22dsdb python tests: fix several usage stringsDouglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-22dsdb sort test: avoid exception with fewer elementsDouglas Bagnall1-1/+1
The FIENDISH_TESTS list has 33 members, and when the number of elements being tested is less than that (because you run the script with, say, --elements=20) some will have a zero count. A recent fix for Python 2.6 didn't take these possible zeros into account. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-22ldb sort tests: point out a known fails against WindowsDouglas Bagnall1-2/+14
It seems that Windows 2012R2 has issues ordering attributes with the "generalized time" syntax (2.5.5.11), and that these show up in our tests when the number of elements exceeds 27. As far as I can tell there is no logic to the results after that point. To avoid failures, use the --elements option, like this: python source4/dsdb/tests/python/sort.py --elements=25 Against Samba this makes no difference because we don't fail. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-11s4:dsdb/test/sort: avoid 'from collections import Counter'Stefan Metzmacher1-2/+7
This is only available in python 2.7 and >= 3.1 This should fix make test with python 2.6. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-03-09ldb sort: allow sorting on attributes not returned in searchDouglas Bagnall1-0/+56
The attribute is added to the search request, then peeled off again before the sort module passes the results on. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-03-09Add python server sort testsDouglas Bagnall1-0/+307
The tests are repeated twice: once properly with complex Unicode strings, and again in a simplified ASCII subset. We only expect Samba to pass the simplified version. The hard tests are aspirational and show what Active Directory does. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>