Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from mojaie/master
Add positioning option to insert_image #117
- Loading branch information
Showing
18 changed files
with
562 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
############################################################################### | ||
# | ||
# Tests for XlsxWriter. | ||
# | ||
# Copyright (c), 2013-2014, John McNamara, jmcnamara@cpan.org | ||
# | ||
|
||
import unittest | ||
import os | ||
from ...workbook import Workbook | ||
from ..helperfunctions import _compare_xlsx_files | ||
|
||
|
||
class TestCompareXLSXFiles(unittest.TestCase): | ||
""" | ||
Test file created by XlsxWriter against a file created by Excel. | ||
""" | ||
|
||
def setUp(self): | ||
self.maxDiff = None | ||
|
||
filename = 'image_anchor01.xlsx' | ||
|
||
test_dir = 'xlsxwriter/test/comparison/' | ||
self.image_dir = test_dir + 'images/' | ||
self.got_filename = test_dir + '_test_' + filename | ||
self.exp_filename = test_dir + 'xlsx_files/' + filename | ||
|
||
self.ignore_files = [] | ||
self.ignore_elements = {} | ||
|
||
def test_create_file(self): | ||
"""Test the creation of a simple XlsxWriter file with image(s).""" | ||
filename = self.got_filename | ||
|
||
#################################################### | ||
|
||
workbook = Workbook(filename) | ||
|
||
worksheet = workbook.add_worksheet() | ||
|
||
worksheet.insert_image( | ||
'E9', self.image_dir + 'red.png', {'positioning': 3}) | ||
|
||
workbook.close() | ||
|
||
#################################################### | ||
|
||
got, exp = _compare_xlsx_files(self.got_filename, | ||
self.exp_filename, | ||
self.ignore_files, | ||
self.ignore_elements) | ||
|
||
self.assertEqual(got, exp) | ||
|
||
def test_create_file_in_memory(self): | ||
"""Test the creation of a simple XlsxWriter file with image(s).""" | ||
filename = self.got_filename | ||
|
||
#################################################### | ||
|
||
workbook = Workbook(filename, {'in_memory': True}) | ||
|
||
worksheet = workbook.add_worksheet() | ||
|
||
worksheet.insert_image( | ||
'E9', self.image_dir + 'red.png', {'positioning': 3}) | ||
|
||
workbook.close() | ||
|
||
#################################################### | ||
|
||
got, exp = _compare_xlsx_files(self.got_filename, | ||
self.exp_filename, | ||
self.ignore_files, | ||
self.ignore_elements) | ||
|
||
self.assertEqual(got, exp) | ||
|
||
def tearDown(self): | ||
# Cleanup. | ||
if os.path.exists(self.got_filename): | ||
os.remove(self.got_filename) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
############################################################################### | ||
# | ||
# Tests for XlsxWriter. | ||
# | ||
# Copyright (c), 2013-2014, John McNamara, jmcnamara@cpan.org | ||
# | ||
|
||
import unittest | ||
import os | ||
from ...workbook import Workbook | ||
from ..helperfunctions import _compare_xlsx_files | ||
|
||
|
||
class TestCompareXLSXFiles(unittest.TestCase): | ||
""" | ||
Test file created by XlsxWriter against a file created by Excel. | ||
""" | ||
|
||
def setUp(self): | ||
self.maxDiff = None | ||
|
||
filename = 'image_anchor02.xlsx' | ||
|
||
test_dir = 'xlsxwriter/test/comparison/' | ||
self.image_dir = test_dir + 'images/' | ||
self.got_filename = test_dir + '_test_' + filename | ||
self.exp_filename = test_dir + 'xlsx_files/' + filename | ||
|
||
self.ignore_files = [] | ||
self.ignore_elements = {} | ||
|
||
def test_create_file(self): | ||
"""Test the creation of a simple XlsxWriter file with image(s).""" | ||
filename = self.got_filename | ||
|
||
#################################################### | ||
|
||
workbook = Workbook(filename) | ||
|
||
worksheet = workbook.add_worksheet() | ||
|
||
worksheet.insert_image( | ||
'E9', self.image_dir + 'red.png', {'positioning': 2}) | ||
|
||
workbook.close() | ||
|
||
#################################################### | ||
|
||
got, exp = _compare_xlsx_files(self.got_filename, | ||
self.exp_filename, | ||
self.ignore_files, | ||
self.ignore_elements) | ||
|
||
self.assertEqual(got, exp) | ||
|
||
def test_create_file_in_memory(self): | ||
"""Test the creation of a simple XlsxWriter file with image(s).""" | ||
filename = self.got_filename | ||
|
||
#################################################### | ||
|
||
workbook = Workbook(filename, {'in_memory': True}) | ||
|
||
worksheet = workbook.add_worksheet() | ||
|
||
worksheet.insert_image( | ||
'E9', self.image_dir + 'red.png', {'positioning': 2}) | ||
|
||
workbook.close() | ||
|
||
#################################################### | ||
|
||
got, exp = _compare_xlsx_files(self.got_filename, | ||
self.exp_filename, | ||
self.ignore_files, | ||
self.ignore_elements) | ||
|
||
self.assertEqual(got, exp) | ||
|
||
def tearDown(self): | ||
# Cleanup. | ||
if os.path.exists(self.got_filename): | ||
os.remove(self.got_filename) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
############################################################################### | ||
# | ||
# Tests for XlsxWriter. | ||
# | ||
# Copyright (c), 2013-2014, John McNamara, jmcnamara@cpan.org | ||
# | ||
|
||
import unittest | ||
import os | ||
from ...workbook import Workbook | ||
from ..helperfunctions import _compare_xlsx_files | ||
|
||
|
||
class TestCompareXLSXFiles(unittest.TestCase): | ||
""" | ||
Test file created by XlsxWriter against a file created by Excel. | ||
""" | ||
|
||
def setUp(self): | ||
self.maxDiff = None | ||
|
||
filename = 'image_anchor03.xlsx' | ||
|
||
test_dir = 'xlsxwriter/test/comparison/' | ||
self.image_dir = test_dir + 'images/' | ||
self.got_filename = test_dir + '_test_' + filename | ||
self.exp_filename = test_dir + 'xlsx_files/' + filename | ||
|
||
self.ignore_files = [] | ||
self.ignore_elements = {} | ||
|
||
def test_create_file(self): | ||
"""Test the creation of a simple XlsxWriter file with image(s).""" | ||
filename = self.got_filename | ||
|
||
#################################################### | ||
|
||
workbook = Workbook(filename) | ||
|
||
worksheet = workbook.add_worksheet() | ||
|
||
worksheet.insert_image( | ||
'E9', self.image_dir + 'red.png', {'positioning': 1}) | ||
|
||
workbook.close() | ||
|
||
#################################################### | ||
|
||
got, exp = _compare_xlsx_files(self.got_filename, | ||
self.exp_filename, | ||
self.ignore_files, | ||
self.ignore_elements) | ||
|
||
self.assertEqual(got, exp) | ||
|
||
def test_create_file_in_memory(self): | ||
"""Test the creation of a simple XlsxWriter file with image(s).""" | ||
filename = self.got_filename | ||
|
||
#################################################### | ||
|
||
workbook = Workbook(filename, {'in_memory': True}) | ||
|
||
worksheet = workbook.add_worksheet() | ||
|
||
worksheet.insert_image( | ||
'E9', self.image_dir + 'red.png', {'positioning': 1}) | ||
|
||
workbook.close() | ||
|
||
#################################################### | ||
|
||
got, exp = _compare_xlsx_files(self.got_filename, | ||
self.exp_filename, | ||
self.ignore_files, | ||
self.ignore_elements) | ||
|
||
self.assertEqual(got, exp) | ||
|
||
def tearDown(self): | ||
# Cleanup. | ||
if os.path.exists(self.got_filename): | ||
os.remove(self.got_filename) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.