mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-22 10:42:34 +01:00
insert local directory into PYTHONPATH when running tests
This commit is contained in:
parent
714566b6e3
commit
5df8f2959b
@ -7,14 +7,19 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
import tempfile
|
|
||||||
import time
|
|
||||||
|
|
||||||
from gallery_dl import config, util
|
import time
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
from gallery_dl import config, util # noqa E402
|
||||||
|
|
||||||
dbpath = tempfile.mkstemp()[1]
|
dbpath = tempfile.mkstemp()[1]
|
||||||
config.set(("cache",), "file", dbpath)
|
config.set(("cache",), "file", dbpath)
|
||||||
from gallery_dl import cache # noqa
|
from gallery_dl import cache # noqa E402
|
||||||
|
|
||||||
|
|
||||||
def tearDownModule():
|
def tearDownModule():
|
||||||
|
@ -7,12 +7,16 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
import unittest
|
|
||||||
import gallery_dl.config as config
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
from gallery_dl import config # noqa E402
|
||||||
|
|
||||||
|
|
||||||
class TestConfig(unittest.TestCase):
|
class TestConfig(unittest.TestCase):
|
||||||
|
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
@ -14,8 +16,8 @@ import logging
|
|||||||
import tempfile
|
import tempfile
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
import gallery_dl.config as config
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
import gallery_dl.extractor as extractor
|
from gallery_dl import config, extractor # noqa E402
|
||||||
|
|
||||||
|
|
||||||
class TestCookiejar(unittest.TestCase):
|
class TestCookiejar(unittest.TestCase):
|
||||||
|
@ -1,29 +1,28 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2018 Mike Fährmann
|
# Copyright 2018-2020 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
import re
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import Mock, MagicMock, patch
|
||||||
|
|
||||||
|
import re
|
||||||
import base64
|
import base64
|
||||||
import os.path
|
import os.path
|
||||||
import tempfile
|
import tempfile
|
||||||
import threading
|
import threading
|
||||||
import http.server
|
import http.server
|
||||||
|
|
||||||
import unittest
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
from unittest.mock import Mock, MagicMock, patch
|
from gallery_dl import downloader, extractor, config, util # noqa E402
|
||||||
|
from gallery_dl.downloader.common import DownloaderBase # noqa E402
|
||||||
import gallery_dl.downloader as downloader
|
from gallery_dl.output import NullOutput # noqa E402
|
||||||
import gallery_dl.extractor as extractor
|
|
||||||
import gallery_dl.config as config
|
|
||||||
from gallery_dl.downloader.common import DownloaderBase
|
|
||||||
from gallery_dl.output import NullOutput
|
|
||||||
from gallery_dl.util import PathFormat
|
|
||||||
|
|
||||||
|
|
||||||
class MockDownloaderModule(Mock):
|
class MockDownloaderModule(Mock):
|
||||||
@ -119,7 +118,7 @@ class TestDownloaderBase(unittest.TestCase):
|
|||||||
"filename": name,
|
"filename": name,
|
||||||
"extension": extension,
|
"extension": extension,
|
||||||
}
|
}
|
||||||
pathfmt = PathFormat(cls.extractor)
|
pathfmt = util.PathFormat(cls.extractor)
|
||||||
pathfmt.set_directory(kwdict)
|
pathfmt.set_directory(kwdict)
|
||||||
pathfmt.set_filename(kwdict)
|
pathfmt.set_filename(kwdict)
|
||||||
|
|
||||||
|
@ -7,18 +7,20 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import string
|
import string
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import unittest
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
from unittest.mock import patch
|
from gallery_dl import extractor # noqa E402
|
||||||
|
from gallery_dl.extractor import mastodon # noqa E402
|
||||||
from gallery_dl import extractor
|
from gallery_dl.extractor.common import Extractor, Message # noqa E402
|
||||||
from gallery_dl.extractor import mastodon
|
from gallery_dl.extractor.directlink import DirectlinkExtractor # noqa E402
|
||||||
from gallery_dl.extractor.common import Extractor, Message
|
|
||||||
from gallery_dl.extractor.directlink import DirectlinkExtractor as DLExtractor
|
|
||||||
|
|
||||||
|
|
||||||
class FakeExtractor(Extractor):
|
class FakeExtractor(Extractor):
|
||||||
@ -78,7 +80,7 @@ class TestExtractorModule(unittest.TestCase):
|
|||||||
test_uri = "test:"
|
test_uri = "test:"
|
||||||
fake_uri = "fake:"
|
fake_uri = "fake:"
|
||||||
|
|
||||||
self.assertIsInstance(extractor.find(link_uri), DLExtractor)
|
self.assertIsInstance(extractor.find(link_uri), DirectlinkExtractor)
|
||||||
self.assertIsInstance(extractor.find(test_uri), Extractor)
|
self.assertIsInstance(extractor.find(test_uri), Extractor)
|
||||||
self.assertIsNone(extractor.find(fake_uri))
|
self.assertIsNone(extractor.find(fake_uri))
|
||||||
|
|
||||||
@ -87,12 +89,12 @@ class TestExtractorModule(unittest.TestCase):
|
|||||||
self.assertIsInstance(extractor.find(test_uri), Extractor)
|
self.assertIsInstance(extractor.find(test_uri), Extractor)
|
||||||
self.assertIsNone(extractor.find(fake_uri))
|
self.assertIsNone(extractor.find(fake_uri))
|
||||||
|
|
||||||
with extractor.blacklist([], [DLExtractor, FakeExtractor]):
|
with extractor.blacklist([], [DirectlinkExtractor, FakeExtractor]):
|
||||||
self.assertIsNone(extractor.find(link_uri))
|
self.assertIsNone(extractor.find(link_uri))
|
||||||
self.assertIsInstance(extractor.find(test_uri), Extractor)
|
self.assertIsInstance(extractor.find(test_uri), Extractor)
|
||||||
self.assertIsNone(extractor.find(fake_uri))
|
self.assertIsNone(extractor.find(fake_uri))
|
||||||
|
|
||||||
with extractor.blacklist(["test"], [DLExtractor]):
|
with extractor.blacklist(["test"], [DirectlinkExtractor]):
|
||||||
self.assertIsNone(extractor.find(link_uri))
|
self.assertIsNone(extractor.find(link_uri))
|
||||||
self.assertIsNone(extractor.find(test_uri))
|
self.assertIsNone(extractor.find(test_uri))
|
||||||
self.assertIsNone(extractor.find(fake_uri))
|
self.assertIsNone(extractor.find(fake_uri))
|
||||||
@ -127,7 +129,8 @@ class TestExtractorModule(unittest.TestCase):
|
|||||||
for extr2 in extractor._cache:
|
for extr2 in extractor._cache:
|
||||||
|
|
||||||
# skip DirectlinkExtractor pattern if it isn't tested
|
# skip DirectlinkExtractor pattern if it isn't tested
|
||||||
if extr1 != DLExtractor and extr2 == DLExtractor:
|
if extr1 != DirectlinkExtractor and \
|
||||||
|
extr2 == DirectlinkExtractor:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
match = extr2.pattern.match(url)
|
match = extr2.pattern.match(url)
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2018 Mike Fährmann
|
# Copyright 2018-2020 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from gallery_dl import oauth, text
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
from gallery_dl import oauth, text # noqa E402
|
||||||
|
|
||||||
TESTSERVER = "http://term.ie/oauth/example"
|
TESTSERVER = "http://term.ie/oauth/example"
|
||||||
CONSUMER_KEY = "key"
|
CONSUMER_KEY = "key"
|
||||||
|
@ -1,23 +1,24 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2019 Mike Fährmann
|
# Copyright 2019-2020 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import sys
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import Mock, mock_open, patch
|
||||||
|
|
||||||
import zipfile
|
import zipfile
|
||||||
import tempfile
|
import tempfile
|
||||||
from datetime import datetime, timezone as tz
|
from datetime import datetime, timezone as tz
|
||||||
|
|
||||||
import unittest
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
from unittest.mock import Mock, mock_open, patch
|
from gallery_dl import postprocessor, extractor, util, config # noqa E402
|
||||||
|
from gallery_dl.postprocessor.common import PostProcessor # noqa E402
|
||||||
from gallery_dl import postprocessor, extractor, util, config
|
|
||||||
from gallery_dl.postprocessor.common import PostProcessor
|
|
||||||
|
|
||||||
|
|
||||||
class MockPostprocessorModule(Mock):
|
class MockPostprocessorModule(Mock):
|
||||||
|
@ -9,12 +9,15 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import datetime
|
import datetime
|
||||||
import unittest
|
|
||||||
from gallery_dl import extractor, util, job, config, exception
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
from gallery_dl import extractor, util, job, config, exception # noqa E402
|
||||||
|
|
||||||
|
|
||||||
# these don't work on Travis CI
|
# these don't work on Travis CI
|
||||||
|
@ -7,10 +7,14 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from gallery_dl import text
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
from gallery_dl import text # noqa E402
|
||||||
|
|
||||||
|
|
||||||
INVALID = ((), [], {}, None, 1, 2.3)
|
INVALID = ((), [], {}, None, 1, 2.3)
|
||||||
|
@ -7,14 +7,17 @@
|
|||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
# published by the Free Software Foundation.
|
# published by the Free Software Foundation.
|
||||||
|
|
||||||
import unittest
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import unittest
|
||||||
|
|
||||||
import io
|
import io
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
import http.cookiejar
|
import http.cookiejar
|
||||||
|
|
||||||
from gallery_dl import util, text, exception
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||||
|
from gallery_dl import util, text, exception # noqa E402
|
||||||
|
|
||||||
|
|
||||||
class TestRange(unittest.TestCase):
|
class TestRange(unittest.TestCase):
|
||||||
|
Loading…
Reference in New Issue
Block a user