internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: tinygrad/tinygrad

Issue:
AssertionError: some input tensors not found
While testing my fix for training CIFAR using CUDA, this error occurred after the latest merge.
![image](https://github.com/tinygrad/tinygrad/assets/17937555/e737d51c-87c9-4916-b038-24cee8724acb)
something related to the fix in #1227 


Discussion:

Resolving patch:
diff --git a/examples/hlb_cifar10.py b/examples/hlb_cifar10.py
--- a/examples/hlb_cifar10.py
+++ b/examples/hlb_cifar10.py
@@ -131,7 +131,7 @@ def eval_step_jitted(model, X, Y):
   left_batcher, right_batcher = fetch_batches(X_train, Y_train, BS=BS, seed=seed, is_train=True), fetch_batches(X_train, Y_train, BS=BS, seed=seed+1, is_train=True)
   while i <= STEPS:
     (Xr, Yr), (Xl, Yl) = next(right_batcher), next(left_batcher)
-    mixup_prob = Tensor(np.random.beta(MIXUP_ALPHA, MIXUP_ALPHA, (1, )).astype(np.float32)) if MIXUP_ALPHA > 0 else Tensor.ones(Xr.shape[0], 1, 1, 1)
+    mixup_prob = Tensor(np.random.beta(MIXUP_ALPHA, MIXUP_ALPHA, (1, )).astype(np.float32)).contiguous() if MIXUP_ALPHA > 0 else Tensor.ones(Xr.shape[0], 1, 1, 1)
     if i%50 == 0 and i > 1:
       # batchnorm is frozen, no need for Tensor.training=False
       corrects = []
diff --git a/extra/lr_scheduler.py b/extra/lr_scheduler.py
--- a/extra/lr_scheduler.py
+++ b/extra/lr_scheduler.py
@@ -66,8 +66,8 @@ def get_lr(self) -> Tensor:
 class OneCycleLR(LR_Scheduler):
   def __init__(self, optimizer: Optimizer, max_lr: float, div_factor: float, final_div_factor: float, total_steps: int, pct_start: float,
                anneal_strategy: str = 'linear', cycle_momentum: bool = False):
-    self.initial_lr = Tensor([max_lr / div_factor])
-    self.max_lr = Tensor([max_lr])
+    self.initial_lr = Tensor([max_lr / div_factor]).contiguous()
+    self.max_lr = Tensor([max_lr]).contiguous()
     self.min_lr = self.initial_lr/final_div_factor
     super().__init__(optimizer)
     self.total_steps = total_steps
diff --git a/tinygrad/nn/optim.py b/tinygrad/nn/optim.py
--- a/tinygrad/nn/optim.py
+++ b/tinygrad/nn/optim.py
@@ -11,7 +11,7 @@ def __init__(self, params: List[Tensor], lr: float):
 
     self.params: List[Tensor] = dedup([x for x in params if x.requires_grad])
     self.buffers: List[Tensor] = dedup([x for x in params if not x.requires_grad])   # buffers are still realized
-    self.lr = Tensor([lr], requires_grad=False)
+    self.lr = Tensor([lr], requires_grad=False).contiguous()
 
   def zero_grad(self):
     for param in self.params: param.grad = None


Test patch:
Repository: tinygrad/tinygrad

Issue:
Tensor.maximum with int tensors broken on interpreted backends
reproduce:
```
Torch or CPU
In [22]: Tensor([20,10,3], dtype=dtypes.int32).maximum(Tensor([20,7,3], dtype=dtypes.int32)).numpy()
Out[22]: array([ 0, 10,  0], dtype=int32)
```
when the case that values equal, maximum sets it to 0


Discussion:

Resolving patch:
diff --git a/tinygrad/tensor.py b/tinygrad/tensor.py
--- a/tinygrad/tensor.py
+++ b/tinygrad/tensor.py
@@ -588,7 +588,7 @@ def _broadcasted(self, y:Union[Tensor, float], reverse:bool=False) -> Tuple[Tens
   def add(self, x:Union[Tensor, float], reverse=False) -> Tensor: return mlops.Add.apply(*self._broadcasted(x, reverse)) if x.__class__ is Tensor or x else self
   def sub(self, x:Union[Tensor, float], reverse=False) -> Tensor: return mlops.Sub.apply(*self._broadcasted(x, reverse)) if x.__class__ is Tensor or x or reverse else self
   def mul(self, x:Union[Tensor, float], reverse=False) -> Tensor: return mlops.Mul.apply(*self._broadcasted(x, reverse)) if x.__class__ is Tensor or x != 1.0 else self
-  def div(self, x:Union[Tensor, float], reverse=False) -> Tensor: return mlops.Div.apply(*self._broadcasted(x, reverse)) if x.__class__ is Tensor or reverse or not x else self.mul(1/x)
+  def div(self, x:Union[Tensor, float], reverse=False) -> Tensor: return mlops.Div.apply(*self._broadcasted(x, reverse)) if x.__class__ is Tensor or reverse or not x or not dtypes.is_float(self.dtype) else self.mul(1/x)
   def pow(self, x:Union[Tensor, float], reverse=False) -> Tensor:
     if x.__class__ is not Tensor and not reverse:
       # simple pow identities


Test patch:
diff --git a/test/test_ops.py b/test/test_ops.py
--- a/test/test_ops.py
+++ b/test/test_ops.py
@@ -212,6 +212,7 @@ def test_maximum(self):
     helper_test_op([(45,65), (45,65)], torch.maximum, Tensor.maximum)
     helper_test_op([(), ()], torch.maximum, Tensor.maximum)
     helper_test_op(None, torch.maximum, Tensor.maximum, vals=[[1., 0., 3., 4.], [1., 2., 3., 0.]])
+    helper_test_op(None, torch.maximum, Tensor.maximum, vals=[[1, 0, 3, 4], [1, 2, 3, 0]], forward_only=True)
   def test_minimum(self):
     helper_test_op([(45,65), (45,65)], torch.minimum, Tensor.minimum)
     helper_test_op([(), ()], torch.minimum, Tensor.minimum)
@@ -246,6 +247,7 @@ def test_div(self):
     helper_test_op([(45,65), (45,65)], lambda x,y: x/y, Tensor.div)
     helper_test_op([(), ()], lambda x,y: x/y, Tensor.div)
     helper_test_op(None, lambda x,y: x/y, Tensor.div, forward_only=True, vals=[[5],[1]])
+    helper_test_op(None, lambda x: (x/2).to(torch.int), lambda x: x/2, forward_only=True, vals=[[3]])
   def test_div_const(self):
     helper_test_op([(45,65)], lambda x: x/255, lambda x: x/255)
     helper_test_op([(45,65)], lambda x: x/1, lambda x: x/1)
Repository: translate/translate

Issue:
incorrect usage of importorskip in storage/test_cpo.py
My understanding of the pytest documentation is that `importorskip` accepts a module name and not any arbitrary expression to be evaluated. In `storage/test_cpo.py`, the intention of:

``` python
cpo = importorskip("not sys.platform.startswith('linux')")
```

is to only run the tests on linux, but the tests do not run on linux either:

```
SKIP [1] /«BUILDDIR»/translate-toolkit-1.12.0+dfsg1/translate/storage/test_cpo.py:7: could not import "not sys.platform.startswith('linux')"
```

Looking more closely:

```
In [1]: import sys
In [2]: sys.platform
Out[2]: 'linux2'
In [3]: from pytest import importorskip, mark, raises
In [4]: cpo = importorskip("not sys.platform.startswith('linux')")
---------------------------------------------------------------------------
Skipped                                   Traceback (most recent call last)
Skipped: could not import "not sys.platform.startswith('linux')"
```

I think the following (untested!) code is more in line with what was actually intended:

``` python
import pytest
if not sys.platform.startswith('linux'):
    pytest.skip("cpo can only be tested on linux")
```



Discussion:
@dwaynebailey any comment on this?


Resolving patch:
diff --git a/translate/storage/cpo.py b/translate/storage/cpo.py
--- a/translate/storage/cpo.py
+++ b/translate/storage/cpo.py
@@ -608,7 +608,7 @@ def buildfromunit(cls, unit, encoding=None):
 class pofile(pocommon.pofile):
     UnitClass = pounit
 
-    def __init__(self, inputfile=None, encoding=None, unitclass=pounit, noheader=False):
+    def __init__(self, inputfile=None, encoding=None, unitclass=pounit, noheader=False, **kwargs):
         self._gpo_memory_file = None
         self._gpo_message_iterator = None
         self.units = []
@@ -621,7 +621,7 @@ def __init__(self, inputfile=None, encoding=None, unitclass=pounit, noheader=Fal
             if not noheader:
                 self.init_headers()
         else:
-            super(pofile, self).__init__(inputfile=inputfile, encoding=encoding)
+            super(pofile, self).__init__(inputfile=inputfile, encoding=encoding, **kwargs)
 
     def addunit(self, unit, new=True):
         if new:


Test patch:
diff --git a/translate/storage/test_cpo.py b/translate/storage/test_cpo.py
--- a/translate/storage/test_cpo.py
+++ b/translate/storage/test_cpo.py
@@ -4,7 +4,11 @@
 import sys
 
 from pytest import importorskip, mark, raises
-cpo = importorskip("not sys.platform.startswith('linux')")
+
+pytestmark = mark.skipif(
+    not sys.platform.startswith('linux'),
+    reason="cpo is only available on Linux"
+)
 
 from translate.misc import wStringIO
 from translate.misc.multistring import multistring
Repository: translate/translate

Issue:
Disable pythonbrace check on LibreOffice
The pythobrace test is not needed by LibreOffice so should be globally disabled for the LibreOffice checker.



Discussion:

Resolving patch:
diff --git a/translate/filters/checks.py b/translate/filters/checks.py
--- a/translate/filters/checks.py
+++ b/translate/filters/checks.py
@@ -2058,6 +2058,11 @@ def validxml(self, str1, str2):
                     raise FilterFailure(u"There is no close tag for %s" % (opentags.pop()))
         return True
 
+    @critical
+    def pythonbraceformat(self, str1, str2):
+        """Not used in LibreOffice"""
+        return True
+
 
 mozillaconfig = CheckerConfig(
     accelmarkers=["&"],


Test patch:
diff --git a/translate/filters/test_checks.py b/translate/filters/test_checks.py
--- a/translate/filters/test_checks.py
+++ b/translate/filters/test_checks.py
@@ -601,6 +601,8 @@ def test_pythonbraceformat():
     assert fails_serious(stdchecker.pythonbraceformat,    "String {}",           "Nommer {1}")
     assert fails_serious(stdchecker.pythonbraceformat,    "String {0}",          "Nommer {1}")
     assert fails_serious(stdchecker.pythonbraceformat,    "String {0} {}",       "Nommer {1}")
+    lochecker = checks.LibreOfficeChecker()
+    assert passes(lochecker.pythonbraceformat, "Time remaining: {[1] minutes }{[2] seconds}", "Tenpo che'l resta: {[1] minuti}{[2] secondi}")
 
     # Named formats
     assert passes(stdchecker.pythonbraceformat, "String {str} and number {num}", "Nommer {num} en string {str}")
Repository: translate/translate

Issue:
json2po output strings in wrong order
Running `json2po` outputs a valid PO files, but the strings are in the wrong order. I’m not sure exactly _which_ order it is, but is _neither_ the original order, the reverse order or alphabetically. Here’s an example JSON file:

``` json
{
    "foo": "foo",
    "bar": "bar",
    "baz": "baz"
}
```

Running `json2po` on this file results in the following (with a PO file header):

``` po
#: .baz
msgid "baz"
msgstr ""

#: .foo
msgid "foo"
msgstr ""

#: .bar
msgid "bar"
msgstr ""
```

Having the strings in a different order than in the original file makes it much harder to correctly translate the file, as one loses context.

I observe this bug both in version 1.13.0 and 1.14.0-rc1.



Discussion:

Resolving patch:
diff --git a/translate/storage/jsonl10n.py b/translate/storage/jsonl10n.py
--- a/translate/storage/jsonl10n.py
+++ b/translate/storage/jsonl10n.py
@@ -70,6 +70,12 @@
 
 import json
 import os
+try:
+    from collections import OrderedDict
+except ImportError:
+    # Python 2.6 does not have OrderedDict and also can't use it in
+    # json.loads()
+    OrderedDict = None
 import six
 
 from translate.storage import base
@@ -214,7 +220,11 @@ def parse(self, input):
         if isinstance(input, bytes):
             input = input.decode('utf-8')
         try:
-            self._file = json.loads(input)
+            if OrderedDict is not None:
+                self._file = json.loads(input, object_pairs_hook=OrderedDict)
+            else:
+                # object_pairs_hook is not present in Python 2.6
+                self._file = json.loads(input)
         except ValueError as e:
             raise base.ParseError(e.message)
 


Test patch:
diff --git a/translate/storage/test_jsonl10n.py b/translate/storage/test_jsonl10n.py
--- a/translate/storage/test_jsonl10n.py
+++ b/translate/storage/test_jsonl10n.py
@@ -1,8 +1,11 @@
 # -*- coding: utf-8 -*-
 
+import sys
 from io import BytesIO
 from translate.storage import jsonl10n, test_monolingual
 
+import pytest
+
 
 class TestJSONResourceUnit(test_monolingual.TestMonolingualUnit):
     UnitClass = jsonl10n.JsonUnit
@@ -18,3 +21,16 @@ def test_serialize(self):
         src = store.serialize(out)
 
         assert out.getvalue() == b'{\n    "key": "value"\n}\n'
+
+    @pytest.mark.skipif(sys.version_info < (2, 7),
+                        reason="json.loads() can't order in Python 2.6")
+    def test_ordering(self):
+        store = jsonl10n.JsonFile()
+        store.parse('''{
+    "foo": "foo",
+    "bar": "bar",
+    "baz": "baz"
+}''')
+
+        assert store.units[0].source == 'foo'
+        assert store.units[2].source == 'baz'
Repository: canonical/snapcraft

Issue:
Logging out from the run environment produces a traceback
(amd64)ubuntu@localhost:~$ logout
Connection to localhost closed.
Traceback (most recent call last):
  File "/usr/bin/snapcraft", line 33, in <module>
    snapcraft.main.main()
  File "/usr/lib/python3/dist-packages/snapcraft/main.py", line 80, in main
    args.func(args)
  File "/usr/lib/python3/dist-packages/snapcraft/cmds.py", line 228, in run
    preexec_fn=os.setsid)
  File "/usr/lib/python3/dist-packages/snapcraft/cmds.py", line 343, in _check_call
    return subprocess.check_call(args, **kwargs)
  File "/usr/lib/python3.4/subprocess.py", line 561, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ssh', '-i', '/home/daniel/.ssh/ubuntudevice_0149BDCB0C009017_id_rsa', '-oStrictHostKeyChecking=no', '-oUserKnownHostsFile=/tmp/tmpcaocvoj7', '-oKbdInteractiveAuthentication=no', '-p', '8022', 'ubuntu@localhost']' returned non-zero exit status 1
daniel@daydream:~/dev/apps/bwm-ng.snap$

Launchpad Details: [#LP1499242](https://bugs.launchpad.net/bugs/1499242) Daniel Holbach - 2015-09-24 06:05:27 -0300



Discussion:
I don't see this on `wily`, on what system does this happen @dholbach ?


Resolving patch:
diff --git a/snapcraft/cmds.py b/snapcraft/cmds.py
--- a/snapcraft/cmds.py
+++ b/snapcraft/cmds.py
@@ -229,7 +229,7 @@ def run(args):
             ['ssh'] + ssh_opts +
             ['ubuntu@localhost', '-p', '8022', 'sudo snappy install  *.snap'])
         # "login"
-        _check_call(
+        _call(
             ['ssh'] + ssh_opts + ['-p', '8022', 'ubuntu@localhost'],
             preexec_fn=os.setsid)
     finally:


Test patch:
Repository: canonical/snapcraft

Issue:
`snapcraft remote-build --launchpad-timeout` does not work
### Bug Description

The argument `--launchpad-timeout` for remote-build stopped being accepted when snapcraft 7 was release.

Scope of work:
1.  Add `--launchpad-timeout` as an argparse argument in `snapcraft/commands/remote.py`
2. Test that it gets passed to the new and fallback remote builders.

### To Reproduce

`snapcraft remote-build --launchpad-timeout <seconds>`

### Environment

n/a

### snapcraft.yaml

```shell
n/a
```


### Relevant log output

```shell
Usage: snapcraft [options] command [args]...
Try 'snapcraft remote-build -h' for help.

Error: unrecognized arguments: --launchpad-timeout 3600
```


### Additional context

_No response_


Discussion:

Resolving patch:
diff --git a/snapcraft/commands/remote.py b/snapcraft/commands/remote.py
--- a/snapcraft/commands/remote.py
+++ b/snapcraft/commands/remote.py
@@ -55,7 +55,13 @@ class RemoteBuildCommand(BaseCommand):
         option, followed by the build number informed when the remote
         build was originally dispatched. The current state of the
         remote build for each architecture can be checked using the
-        --status option."""
+        --status option.
+
+        To set a timeout on the remote-build command, use the option
+        ``--launchpad-timeout=<seconds>``. The timeout is local, so the build on
+        launchpad will continue even if the local instance of snapcraft is
+        interrupted or times out.
+        """
     )
 
     @overrides
@@ -87,6 +93,13 @@ def fill_parser(self, parser: argparse.ArgumentParser) -> None:
             action="store_true",
             help="acknowledge that uploaded code will be publicly available.",
         )
+        parser.add_argument(
+            "--launchpad-timeout",
+            type=int,
+            default=0,
+            metavar="<seconds>",
+            help="Time in seconds to wait for launchpad to build.",
+        )
 
     @overrides
     def run(self, parsed_args):


Test patch:
Repository: canonical/snapcraft

Issue:
Validate component names do not begin with `snap-`
### What needs to get done

Component names in a `snapcraft.yaml` cannot begin with `snap-`. 

### Why it needs to get done

These names are reserved for `snapd`.


Discussion:

Resolving patch:
diff --git a/snapcraft/projects.py b/snapcraft/projects.py
--- a/snapcraft/projects.py
+++ b/snapcraft/projects.py
@@ -216,6 +216,11 @@ def _validate_component_name(name: str) -> None:
             "Component names can only use ASCII lowercase letters and hyphens"
         )
 
+    if name.startswith("snap-"):
+        raise ValueError(
+            "Component names cannot start with the reserved namespace 'snap-'"
+        )
+
     if name.startswith("-"):
         raise ValueError("Component names cannot start with a hyphen")
 


Test patch:
diff --git a/tests/unit/test_projects.py b/tests/unit/test_projects.py
--- a/tests/unit/test_projects.py
+++ b/tests/unit/test_projects.py
@@ -1828,7 +1828,9 @@ def test_component_type_invalid(
         with pytest.raises(errors.ProjectValidationError, match=error):
             project.unmarshal(project_yaml_data(components=component))
 
-    @pytest.mark.parametrize("name", ["name", "name-with-dashes", "x" * 40])
+    @pytest.mark.parametrize(
+        "name", ["name", "name-with-dashes", "x" * 40, "foo-snap-bar"]
+    )
     def test_component_name_valid(
         self, project, name, project_yaml_data, stub_component_data
     ):
@@ -1842,6 +1844,14 @@ def test_component_name_valid(
     @pytest.mark.parametrize(
         "name,error",
         [
+            (
+                "snap-",
+                "Component names cannot start with the reserved namespace 'snap-'",
+            ),
+            (
+                "snap-foo",
+                "Component names cannot start with the reserved namespace 'snap-'",
+            ),
             ("123456", "Component names can only use"),
             ("name-ends-with-digits-0123", "Component names can only use"),
             ("456-name-starts-with-digits", "Component names can only use"),
Repository: adamchainz/django-cors-headers

Issue:
Default allow_headers breaks JSON in Safari
Not sure if this should be added to the defaults or simply mentioned in the relevant section of the README, but communicating in JSON on Safari causes the following error: 

```
Failed to load resource: Request header field Accept-Encoding is not allowed by Access-Control-Allow-Headers.

[Error] XMLHttpRequest cannot load http://mydomain.com/mypath. Request header field Accept-Encoding is not allowed by Access-Control-Allow-Headers. (localhost, line 0)
```

The fix is to add 'accept-encoding' to CORS_ALLOW_HEADERS



Discussion:
:+1: Just got bitten by this too. (Think it was "user-agent" for me though.)


Resolving patch:
diff --git a/corsheaders/defaults.py b/corsheaders/defaults.py
--- a/corsheaders/defaults.py
+++ b/corsheaders/defaults.py
@@ -7,7 +7,10 @@
     'origin',
     'authorization',
     'x-csrftoken',
+    'user-agent',
+    'accept-encoding',
 )
+
 CORS_ALLOW_HEADERS = getattr(settings, 'CORS_ALLOW_HEADERS', default_headers)
 
 default_methods = (
@@ -28,7 +31,10 @@
 
 CORS_ORIGIN_WHITELIST = getattr(settings, 'CORS_ORIGIN_WHITELIST', ())
 
-CORS_ORIGIN_REGEX_WHITELIST = getattr(settings, 'CORS_ORIGIN_REGEX_WHITELIST', ())
+CORS_ORIGIN_REGEX_WHITELIST = getattr(
+    settings,
+    'CORS_ORIGIN_REGEX_WHITELIST',
+    ())
 
 CORS_EXPOSE_HEADERS = getattr(settings, 'CORS_EXPOSE_HEADERS', ())
 


Test patch:
Repository: adamchainz/django-cors-headers

Issue:
Test with tox only
We should use the `tox` config on Travis so it's easy to locally run exactly what gets run on Travis. Maintaining two grids of tests is a pain.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -23,17 +23,15 @@
         'Development Status :: 5 - Production/Stable',
         'Environment :: Web Environment',
         'Framework :: Django',
+        'Framework :: Django :: 1.8',
         'Intended Audience :: Developers',
         'License :: OSI Approved :: MIT License',
         'Operating System :: OS Independent',
         'Programming Language :: Python',
         'Programming Language :: Python :: 2',
-        'Programming Language :: Python :: 2.6',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.2',
-        'Programming Language :: Python :: 3.3',
-        'Programming Language :: Python :: 3.4',
+        'Programming Language :: Python :: 3.5',
         'Topic :: Software Development :: Libraries :: Application Frameworks',
         'Topic :: Software Development :: Libraries :: Python Modules',
     ],


Test patch:
Repository: adamchainz/django-cors-headers

Issue:
Django 1.9 Support
Take the changes from the fork mentioned in #81 .



Discussion:

Resolving patch:
diff --git a/corsheaders/middleware.py b/corsheaders/middleware.py
--- a/corsheaders/middleware.py
+++ b/corsheaders/middleware.py
@@ -6,11 +6,7 @@
 except ImportError:
     from urllib.parse import urlparse
 
-try:
-    from django.apps import apps
-    get_model = apps.get_model
-except ImportError:
-    from django.db.models.loading import get_model
+from django.apps import apps
 
 from corsheaders import defaults as settings
 
@@ -109,7 +105,7 @@ def process_response(self, request, response):
             url = urlparse(origin)
 
             if settings.CORS_MODEL is not None:
-                model = get_model(*settings.CORS_MODEL.split('.'))
+                model = apps.get_model(*settings.CORS_MODEL.split('.'))
                 if model.objects.filter(cors=url.netloc).exists():
                     response[ACCESS_CONTROL_ALLOW_ORIGIN] = origin
 
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -24,6 +24,7 @@
         'Environment :: Web Environment',
         'Framework :: Django',
         'Framework :: Django :: 1.8',
+        'Framework :: Django :: 1.9',
         'Intended Audience :: Developers',
         'License :: OSI Approved :: MIT License',
         'Operating System :: OS Independent',


Test patch:
diff --git a/tests.py b/tests.py
--- a/tests.py
+++ b/tests.py
@@ -6,8 +6,12 @@
 
 def run_tests():
     import django
-    from django.conf import global_settings
-    from django.conf import settings
+    from django.conf import global_settings, settings
+    from django.test.runner import DiscoverRunner
+
+    middleware = list(global_settings.MIDDLEWARE_CLASSES)
+    middleware.append('corsheaders.middleware.CorsMiddleware')
+
     settings.configure(
         INSTALLED_APPS=[
             'corsheaders',
@@ -18,18 +22,11 @@ def run_tests():
                 'TEST_NAME': ':memory:',
             },
         },
-        MIDDLEWARE_CLASSES=global_settings.MIDDLEWARE_CLASSES + (
-            'corsheaders.middleware.CorsMiddleware',),
+        MIDDLEWARE_CLASSES=middleware,
     )
-    if hasattr(django, 'setup'):
-        django.setup()
-
-    try:
-        from django.test.runner import DiscoverRunner as Runner
-    except ImportError:
-        from django.test.simple import DjangoTestSuiteRunner as Runner
+    django.setup()
 
-    test_runner = Runner(verbosity=1)
+    test_runner = DiscoverRunner(verbosity=1)
     return test_runner.run_tests(['corsheaders'])
Repository: adamchainz/django-cors-headers

Issue:
Add DNT to default allowed headers
Discussed in #78, PR exists at zestedesavoir/django-cors-middleware#8



Discussion:

Resolving patch:
diff --git a/corsheaders/defaults.py b/corsheaders/defaults.py
--- a/corsheaders/defaults.py
+++ b/corsheaders/defaults.py
@@ -1,19 +1,20 @@
 default_headers = (
-    'x-requested-with',
-    'content-type',
     'accept',
-    'origin',
+    'accept-encoding',
     'authorization',
-    'x-csrftoken',
+    'content-type',
+    'dnt',
+    'origin',
     'user-agent',
-    'accept-encoding',
+    'x-csrftoken',
+    'x-requested-with',
 )
 
 default_methods = (
+    'DELETE',
     'GET',
+    'OPTIONS',
+    'PATCH',
     'POST',
     'PUT',
-    'PATCH',
-    'DELETE',
-    'OPTIONS',
 )


Test patch: