From a1b0104f3d81b8323c9968649501d662301e04b8 Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Mon, 17 Aug 2015 12:43:13 -0700 Subject: [PATCH] Sort requirements.txt case-insensitively --- pre_commit_hooks/requirements_txt_fixer.py | 4 ++-- tests/requirements_txt_fixer_test.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pre_commit_hooks/requirements_txt_fixer.py b/pre_commit_hooks/requirements_txt_fixer.py index cc09242..bf7f75d 100644 --- a/pre_commit_hooks/requirements_txt_fixer.py +++ b/pre_commit_hooks/requirements_txt_fixer.py @@ -19,8 +19,8 @@ class Requirement(object): return False else: return ( - self.value.partition(b'==') < - requirement.value.partition(b'==') + self.value.lower().partition(b'==') < + requirement.value.lower().partition(b'==') ) diff --git a/tests/requirements_txt_fixer_test.py b/tests/requirements_txt_fixer_test.py index 3eac637..3680733 100644 --- a/tests/requirements_txt_fixer_test.py +++ b/tests/requirements_txt_fixer_test.py @@ -16,6 +16,7 @@ TESTS = ( (b'\nfoo\nbar\n', 1, b'bar\n\nfoo\n'), (b'\nbar\nfoo\n', 0, b'\nbar\nfoo\n'), (b'pyramid==1\npyramid-foo==2\n', 0, b'pyramid==1\npyramid-foo==2\n'), + (b'ocflib\nDjango\nPyMySQL\n', 1, b'Django\nocflib\nPyMySQL\n'), )