ó
P'—^c           @@  s   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 d  d l
 m Z d  d l m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z m Z y d  d l  Z  Wn e! k
 r!d Z  n Xd  d l# m$ Z$ m% Z% m& Z& m' Z' m( Z( m) Z) m* Z* m+ Z+ d e$ f d	 „  ƒ  YZ, d
 e$ f d „  ƒ  YZ- d e$ f d „  ƒ  YZ. d e$ f d „  ƒ  YZ/ d e$ f d „  ƒ  YZ0 d e$ f d „  ƒ  YZ1 e	 j2 sœd e$ f d „  ƒ  YZ3 d e$ f d „  ƒ  YZ4 d e$ f d „  ƒ  YZ5 d e$ f d „  ƒ  YZ6 d e$ f d „  ƒ  YZ7 d e$ f d „  ƒ  YZ8 d  e$ f d! „  ƒ  YZ9 d" e$ f d# „  ƒ  YZ: n  d S($   i    (   t   absolute_importN(   t   _find_option_with_arg(   t	   platforms(   t	   open_fqdn(   t	   get_fdmaxt   ignore_errnot   set_process_titlet   signalst   maybe_drop_privilegest   setuidt   setgidt
   initgroupst	   parse_uidt	   parse_gidt   detachedt   DaemonContextt   create_pidlockt   Pidfilet
   LockFailedt	   setgroupst   _setgroups_hackt   close_open_fdst
   fd_by_path(   t   Caset
   WhateverIOt   Mockt   SkipTestt   callt   override_stdoutst	   mock_opent   patcht   test_find_option_with_argc           B@  s   e  Z d  „  Z d „  Z RS(   c         C@  s&   |  j  t d g d d g ƒd ƒ d  S(   Ns	   --foo=bart	   long_optss   --foot   bar(   t   assertEqualR   (   t   self(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_long_opt/   s    c         C@  s)   |  j  t d d g d d g ƒd ƒ d  S(   Ns   -fR!   t
   short_opts(   R"   R   (   R#   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_short_opt5   s    (   t   __name__t
   __module__R$   R&   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR   -   s   	t   test_fd_by_pathc           B@  s   e  Z d  „  Z RS(   c         C@  sH   t  j ƒ  } t | j g ƒ } |  j | | j j ƒ  g ƒ | j ƒ  d  S(   N(   t   tempfilet   NamedTemporaryFileR   t   nameR"   t   filet   filenot   close(   R#   t	   test_filet   keep(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt
   test_finds>   s    (   R'   R(   R2   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR)   <   s   t   test_close_open_fdsc           B@  s   e  Z d  „  Z RS(   c         C@  s¯   t  d ƒ  } t  d d t ƒ‚ } t  d ƒ m } d | _ t ƒ  | j s’ | j t d ƒ t d ƒ t d ƒ g ƒ t ƒ  | _ t	 j
 | j _	 n  t ƒ  Wd  QXWd  QXWd  QXd  S(	   Ns   os.closes   os.closeranget   creates   celery.platforms.get_fdmaxi   i   i   i    (   R   t   Truet   return_valueR   t   calledt   assert_has_callsR   t   OSErrort   side_effectt   errnot   EBADF(   R#   t   _closet
   closeranget   fdmax(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_closesG   s    		((   R'   R(   R@   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR3   E   s   t   test_ignore_errnoc           B@  s   e  Z d  „  Z d „  Z RS(   c         C@  s2   t  d ƒ   t ƒ  } t j | _ | ‚ Wd  QXd  S(   NR<   (   R   R9   R;   R<   (   R#   t   exc(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_raises_EBADFV   s    	c      
   C@  sH   |  j  t ƒ 3 t d ƒ   t ƒ  } t j | _ | ‚ Wd  QXWd  QXd  S(   NR<   (   t   assertRaisesR9   R   R;   t   ENOENT(   R#   RB   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_otherwise\   s
    	(   R'   R(   RC   RF   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyRA   T   s   	t   test_set_process_titlec           B@  s   e  Z d  „  Z RS(   c         C@  s5   t  j d  f } t  _ z t d ƒ Wd  | t  _ Xd  S(   Nt   foo(   R   t   _setproctitlet   NoneR   (   R#   t   prev(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   when_no_setpsf   s    (   R'   R(   RL   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyRG   d   s   t   test_Signalsc           B@  s€   e  Z e d  ƒ d „  ƒ Z d „  Z d „  Z d „  Z d „  Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z	 e d ƒ d	 „  ƒ Z
 RS(
   s   signal.getsignalc         C@  s   t  d | j t j ƒ d  S(   Nt   SIGINT(   R   t   assert_called_witht   signalRN   (   R#   t	   getsignal(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_getitemp   s    c         C@  s0   |  j  t j d ƒ ƒ |  j t j d ƒ ƒ d  S(   Nt   INTt   SIGIMAGINARY(   t
   assertTrueR   t	   supportedt   assertFalse(   R#   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_supportedu   s    c         C@  sN   t  j d k r t d ƒ ‚ n  t d ƒ  } t j ƒ  | j d ƒ Wd  QXd  S(   Nt   win32s%   signal.alarm not available on Windowss   signal.alarmi    (   t   syst   platformR   R   R   t   reset_alarmRO   (   R#   t   _alarm(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_reset_alarmy   s
    
c         C@  sN   t  t d ƒ rJ t d d t ƒ$ } t j d ƒ |  j | j ƒ Wd  QXn  d  S(   Nt	   setitimers   signal.setitimerR4   i   (   t   hasattrRP   R   R5   R   t	   arm_alarmRU   R7   (   R#   t   seti(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_arm_alarm€   s    c         C@  sˆ   |  j  t j d ƒ d ƒ |  j  t j d ƒ t j ƒ |  j  t j d ƒ t j ƒ |  j t ƒ " t j d ƒ t j t ƒ  ƒ Wd  QXd  S(   Ni   RS   RN   t   int(   R"   R   t   signumRP   RN   RD   t	   TypeErrort   object(   R#   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_signum†   s    s   signal.signalc         C@  sV   t  j d ƒ | j t  j d ƒ t  j ƒ t  j d ƒ | j t  j d ƒ t  j ƒ d  S(   NRN   RS   t   SIGTERMt   TERM(   R   t   ignoreRO   Re   t   ignored(   R#   t   set(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_ignoreŽ   s    c         C@  s*   d „  } | t  d <| j t j | ƒ d  S(   Nc          W@  s   |  S(   N(    (   t   a(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   handle—   s    RS   (   R   RO   RP   RN   (   R#   Rm   Rp   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setitem•   s    	
c         C@  s   t  ƒ  | _ d „  t d <d  S(   Nc          W@  s   |  S(   N(    (   Ro   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   <lambda>Ÿ   t    RS   (   t
   ValueErrorR:   R   (   R#   Rm   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setitem_raisesœ   s    (   R'   R(   R   RR   RX   R^   Rc   Rh   Rn   Rq   Ru   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyRM   n   s   				t   test_get_fdmaxc           B@  s2   e  Z e d  ƒ d „  ƒ Z e d  ƒ d „  ƒ Z RS(   s   resource.getrlimitc         C@  sV   t  d ƒ D } t ƒ  | _ d  t j g | _ t ƒ  } |  j t	 | ƒ | ƒ Wd  QXd  S(   Ns
   os.sysconf(
   R   t   KeyErrorR:   RJ   t   resourcet   RLIM_INFINITYR6   Rg   t   assertIsR   (   R#   t	   getrlimitt	   sysconfigt   default(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_when_infinity¦   s
    	c         C@  sJ   t  d ƒ 8 } t ƒ  | _ d  d g | _ |  j t d  ƒ d ƒ Wd  QXd  S(   Ns
   os.sysconfi   (   R   Rw   R:   RJ   R6   R"   R   (   R#   R{   R|   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_when_actual®   s    (   R'   R(   R   R~   R   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyRv   ¤   s   t   test_maybe_drop_privilegesc           B@  s¿   e  Z e d  ƒ e d ƒ e d ƒ e d ƒ e d ƒ d „  ƒ ƒ ƒ ƒ ƒ Z e d  ƒ e d ƒ e d ƒ e d ƒ e d ƒ d „  ƒ ƒ ƒ ƒ ƒ Z e d ƒ e d ƒ e d ƒ d „  ƒ ƒ ƒ Z RS(	   s   celery.platforms.parse_uids   pwd.getpwuids   celery.platforms.setgids   celery.platforms.setuids   celery.platforms.initgroupsc         @  sª   d t  f d „  ƒ  Y} ‡  f d †  } | ˆ  _ | ƒ  | _ d | _ t d d ƒ | j d ƒ | j d ƒ | j d ƒ | j d d ƒ ˆ  j t d ƒ t d ƒ g ƒ d  S(	   Nt	   pw_structc           B@  s   e  Z d  Z RS(   iQÃ  (   R'   R(   t   pw_gid(    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR   ¿   s   c          @  s   t  ƒ  ˆ  _ t j ˆ  j _ d  S(   N(   R9   R:   R;   t   EPERM(   t   argst   kwargs(   R	   (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   raise_on_second_callÂ   s    i‰  t   uidt   useriQÃ  i    (   Rg   R:   R6   R   RO   R8   R   (   R#   R   R	   R
   t   getpwuidR   R   R†   (    (   R	   sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_with_uid·   s    		s   celery.platforms.parse_gidc      
   @  s  ‡  f d †  } | ˆ  _  d | _ d | _ t d d d d ƒ | j d ƒ | j d ƒ | j d ƒ | j d d ƒ ˆ  j t d ƒ t d ƒ g ƒ d  ˆ  _  |  j t ƒ  t d d d d ƒ Wd  QXt	 ƒ  ˆ  _  t
 j ˆ  j  _
 |  j t	 ƒ  t d d d d ƒ Wd  QXd  S(	   Nc          @  s   t  ƒ  ˆ  _ t j ˆ  j _ d  S(   N(   R9   R:   R;   Rƒ   (   R„   R…   (   R	   (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR†   ×   s    i‰  iQÃ  R‡   Rˆ   t   gidt   groupi    (   R:   R6   R   RO   R8   R   RJ   RD   t   RuntimeErrorR9   R;   t   EINVAL(   R#   R   R	   R
   R   R   R†   (    (   R	   sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_with_guidÏ   s"    				c         C@  sD   d | _  t d d ƒ | j d ƒ | j d ƒ |  j | j ƒ d  S(   NiQÃ  R‹   RŒ   (   R6   R   RO   RW   R7   (   R#   R   R
   R	   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_only_gidì   s
    	(   R'   R(   R   RŠ   R   R   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR€   µ   s   				!				!		t   test_setget_uid_gidc           B@  s°   e  Z e d  ƒ e d ƒ d „  ƒ ƒ Z e d ƒ e d ƒ d „  ƒ ƒ Z d „  Z e d ƒ d „  ƒ Z e d ƒ d	 „  ƒ Z d
 „  Z e d ƒ d „  ƒ Z	 e d ƒ d „  ƒ Z
 RS(   s   celery.platforms.parse_uids	   os.setuidc         C@  s1   d | _  t d ƒ | j d ƒ | j d ƒ d  S(   Ni‰  Rˆ   (   R6   R	   RO   (   R#   t   _setuidR   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setuidø   s    	
s   celery.platforms.parse_gids	   os.setgidc         C@  s1   d | _  t d ƒ | j d ƒ | j d ƒ d  S(   NiQÃ  RŒ   (   R6   R
   RO   (   R#   t   _setgidR   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setgid   s    	
c         C@  s   |  j  t d ƒ d ƒ d  S(   Ni‰  (   R"   R   (   R#   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_parse_uid_when_int  s    s   pwd.getpwnamc         C@  s<   d t  f d „  ƒ  Y} | ƒ  | _ |  j t d ƒ d ƒ d  S(   Nt   pwentc           B@  s   e  Z d  Z RS(   i‰  (   R'   R(   t   pw_uid(    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR—     s   Rˆ   i‰  (   Rg   R6   R"   R   (   R#   t   getpwnamR—   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt!   test_parse_uid_when_existing_name  s    c         C@  s3   t  d ƒ | _ |  j t  ƒ  t d ƒ Wd  QXd  S(   NRˆ   (   Rw   R:   RD   R   (   R#   R™   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt$   test_parse_uid_when_nonexisting_name  s    c         C@  s   |  j  t d ƒ d ƒ d  S(   NiQÃ  (   R"   R   (   R#   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_parse_gid_when_int  s    s   grp.getgrnamc         C@  s<   d t  f d „  ƒ  Y} | ƒ  | _ |  j t d ƒ d ƒ d  S(   Nt   grentc           B@  s   e  Z d  Z RS(   iQÃ  (   R'   R(   t   gr_gid(    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR   !  s   RŒ   iQÃ  (   Rg   R6   R"   R   (   R#   t   getgrnamR   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt!   test_parse_gid_when_existing_name  s    c         C@  s3   t  d ƒ | _ |  j t  ƒ  t d ƒ Wd  QXd  S(   NRŒ   (   Rw   R:   RD   R   (   R#   RŸ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt$   test_parse_gid_when_nonexisting_name'  s    (   R'   R(   R   R“   R•   R–   Rš   R›   Rœ   R    R¡   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR‘   ö   s   						t   test_initgroupsc           B@  s\   e  Z e d  ƒ e d d e ƒd „  ƒ ƒ Z e d ƒ e d ƒ e d  ƒ d „  ƒ ƒ ƒ Z RS(   s   pwd.getpwuids   os.initgroupsR4   c         C@  s-   d g | _  t d d ƒ | j d d ƒ d  S(   NRˆ   i‰  iQÃ  (   R6   R   RO   (   R#   t   initgroups_R‰   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_with_initgroups0  s    s   celery.platforms.setgroupss   grp.getgrallc         C@  s¾   t  t d d  ƒ } y t t d ƒ Wn t k
 r6 n Xzm d g | _ d t f d „  ƒ  Y} | d ƒ | d ƒ | d ƒ g | _ t d d	 ƒ | j d d d g ƒ Wd  | r¹ | t _ n  Xd  S(
   NR   Rˆ   R   c           B@  s   e  Z d  g Z d „  Z RS(   Rˆ   c         S@  s   | |  _  d  S(   N(   Rž   (   R#   R‹   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   __init__F  s    (   R'   R(   t   gr_memR¥   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR   C  s   	i   i   i   i‰  iQÃ  (	   t   getattrt   osRJ   t   delattrt   AttributeErrorR6   Rg   R   RO   (   R#   R‰   t   getgrallR   RK   R   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_without_initgroups7  s    $(   R'   R(   R   R5   R¤   R¬   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR¢   .  s
   			t   test_detachedc           B@  sV   e  Z d  „  Z e d ƒ e d ƒ e d ƒ e d ƒ e e ƒ d „  ƒ ƒ ƒ ƒ ƒ Z RS(   c         C@  sE   t  j d  } t  _ z! |  j t ƒ  t ƒ  Wd  QXWd  | t  _ Xd  S(   N(   R   Rx   RJ   RD   R   R   (   R#   RK   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_without_resourceR  s
    s    celery.platforms._create_pidlocks   celery.platforms.signalss&   celery.platforms.maybe_drop_privilegess
   os.geteuidc         C@  s  d | _  t d d d d ƒ } |  j | t ƒ | j j d ƒ | j d d d d ƒ t ƒ  | _  d | _  t d d d d d d	 ƒ } |  j | t ƒ |  j | j ƒ | j ƒ  | j d	 d
 ƒ | j  j	 j ƒ  t d d ƒ } |  j | t ƒ |  j | j ƒ | j ƒ  | j d ƒ d  S(   Ni    R‡   Rˆ   R‹   RŒ   t   SIGCLDi‰  t   logfiles   /foo/barRo   t   pidfiles   /foo/bar/pid(
   R6   R   t   assertIsInstanceR   t   resetRO   R   RU   t   after_chdirR/   (   R#   t   opent   geteuidt
   maybe_dropR   t   pidlockt   context(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_defaultZ  s$    		

(   R'   R(   R®   R   R   Rº   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR­   P  s   					t   test_DaemonContextc        
   B@  s}   e  Z e d  ƒ e d ƒ e d ƒ e d ƒ e d ƒ e d ƒ e d ƒ e d ƒ e d ƒ d	 „  ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ ƒ Z RS(
   s   os.forks	   os.setsids   os._exits   os.chdirs   os.umasks   os.closes   os.closeranges   os.opens   os.dup2c
      	   C@  s’  t  d d d d ƒ }
 d d d g |
 _ d |	 _ |
 " |  j |
 j ƒ |
  Wd  QXWd  QX|  j |	 j d ƒ | j ƒ  |  j | j	 ƒ | j |
 j
 ƒ | j d ƒ |  j | j	 ƒ |	 j ƒ  d |	 _ t  d d ƒ }
 d d d g |
 _ |
  Wd  QX|  j |	 j d ƒ | j d ƒ t  d d d t ƒ }
 d d d g |
 _ t ƒ  |
 _ |
  Wd  QX|  j |
 j j	 ƒ t ƒ  |
 _ |
  Wd  QX|
 j j ƒ  d  S(	   Nt   workdirs   /opt/workdirt   umaski   i    i   i   t   fake(   R   t   stdfdsR6   RU   t   _is_openR"   t
   call_countRO   RW   R7   R¼   t
   reset_mockR5   R   t   _detachR´   (   R#   t   dup2Rµ   R/   t   closerR½   t   chdirt   _exitt   setsidt   forkt   x(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt	   test_openx  s>    	

	(   R'   R(   R   RË   (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR»   v  s   								t   test_Pidfilec           B@  s‹  e  Z e d  ƒ d „  ƒ Z d „  Z d „  Z e d ƒ d „  ƒ Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z e d ƒ d „  ƒ Z d „  Z d „  Z e d ƒ e d ƒ e d ƒ e d ƒ e e ƒ d „  ƒ ƒ ƒ ƒ ƒ Z e d ƒ e d ƒ e d ƒ e d ƒ e e ƒ d „  ƒ ƒ ƒ ƒ ƒ Z RS(   s   celery.platforms.Pidfilec      
   C@  s¢   t  ƒ  } | _ t | j _ t | j _ t ƒ  C \ } } |  j t ƒ  t	 d ƒ Wd  QX|  j
 d | j ƒ  ƒ Wd  QXt | j _ t	 d ƒ } |  j | | ƒ d  S(   Ns   /var/pids   already exists(   R   R6   R5   t	   is_lockedt   Falset   remove_if_staleR   RD   t
   SystemExitR   t   assertInt   getvalueRz   (   R#   R   t   pt   _t   errt   ret(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_create_pidlockª  s    c         C@  sa   t  d ƒ } t ƒ  | _ t ƒ  | _ |  } |  j | | ƒ Wd  QX| j j ƒ  | j j ƒ  d  S(   Ns   /var/pid(   R   R   t	   write_pidt   removeRz   RO   (   R#   RÓ   t   _p(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_context¸  s    	c      	   C@  sN   t  d ƒ } t ƒ  | _ t ƒ  | j _ |  j t ƒ  |  Wd  QXWd  QXd  S(   Ns   /var/pid(   R   R   RØ   R9   R:   RD   R   (   R#   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_acquire_raises_LockFailedÂ  s    s   os.path.existsc         C@  sH   t  d ƒ } t | _ |  j | j ƒ  ƒ t | _ |  j | j ƒ  ƒ d  S(   Ns   /var/pid(   R   R5   R6   RU   RÍ   RÎ   RW   (   R#   t   existsRÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_is_lockedË  s
    		c         C@  sR   t  ƒ  C } | j d ƒ | j d ƒ t d ƒ } |  j | j ƒ  d ƒ Wd  QXd  S(   Ns   1816
i    s   /var/pidi  (   R   t   writet   seekR   R"   t   read_pid(   R#   t   sRÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_read_pidÓ  s
    c      	   C@  s\   t  ƒ  M } | j d ƒ | j d ƒ t d ƒ } |  j t ƒ  | j ƒ  Wd  QXWd  QXd  S(   Nt   1816i    s   /var/pid(   R   Rß   Rà   R   RD   Rt   Rá   (   R#   Râ   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_read_pid_partially_writtenÚ  s    c         C@  sN   t  ƒ  } t j | _ t d | ƒ $ t d ƒ } |  j | j ƒ  ƒ Wd  QXd  S(   NR:   s   /var/pid(   t   IOErrorR;   RE   R   R   t   assertIsNoneRá   (   R#   RB   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_read_pid_raises_ENOENTâ  s
    	c      	   C@  s[   t  ƒ  } t j | _ t d | ƒ 1 t d ƒ } |  j t  ƒ  | j ƒ  Wd  QXWd  QXd  S(   NR:   s   /var/pid(   Ræ   R;   t   EAGAINR   R   RD   Rá   (   R#   RB   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_read_pid_raises_IOErroré  s    	c      	   C@  s\   t  ƒ  M } | j d ƒ | j d ƒ t d ƒ } |  j t ƒ  | j ƒ  Wd  QXWd  QXd  S(   Ns   eighteensixteen
i    s   /var/pid(   R   Rß   Rà   R   RD   Rt   Rá   (   R#   Râ   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_read_pid_bogus_pidfileñ  s    s	   os.unlinkc         C@  s3   t  | _ t d ƒ } | j ƒ  | j | j ƒ d  S(   Ns   /var/pid(   R5   R6   R   RÙ   RO   t   path(   R#   t   unlinkRÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_removeù  s    	
c         C@  sH   t  ƒ  } t j | _ | | _ t d ƒ } | j ƒ  | j | j ƒ d  S(   Ns   /var/pid(   R9   R;   RE   R:   R   RÙ   RO   Rì   (   R#   Rí   RB   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_remove_ENOENT   s    		
c         C@  sH   t  ƒ  } t j | _ | | _ t d ƒ } | j ƒ  | j | j ƒ d  S(   Ns   /var/pid(   R9   R;   t   EACCESR:   R   RÙ   RO   Rì   (   R#   Rí   RB   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_remove_EACCES	  s    		
c         C@  s^   t  ƒ  } t j | _ | | _ t d ƒ } |  j t  ƒ  | j ƒ  Wd  QX| j | j ƒ d  S(   Ns   /var/pid(	   R9   R;   Ré   R:   R   RD   RÙ   RO   Rì   (   R#   Rí   RB   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_remove_OSError  s    		s   os.killc         C@  s   t  d ƒ } t ƒ  | _ d | j _ d | _ |  j | j ƒ  ƒ | j d d ƒ | j j ƒ  t ƒ  | _ t	 j
 | j _	 |  j | j ƒ  ƒ d  S(   Ns   /var/pidi  i    (   R   R   Rá   R6   RW   RÏ   RO   R9   R:   R;   RE   (   R#   t   killRÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt"   test_remove_if_stale_process_alive  s    	c         C@  s’   t  ƒ  ƒ t d ƒ } t ƒ  | _ d | j _ t ƒ  | _ t ƒ  } t j | _ | | _	 |  j
 | j ƒ  ƒ | j d d ƒ | j j ƒ  Wd  QXd  S(   Ns   /var/pidi  i    (   R   R   R   Rá   R6   RÙ   R9   R;   t   ESRCHR:   RU   RÏ   RO   (   R#   Ró   RÓ   RB   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt!   test_remove_if_stale_process_dead*  s    
		c         C@  sg   t  ƒ  X t d ƒ } t ƒ  | _ t ƒ  | j _ t ƒ  | _ |  j | j ƒ  ƒ | j j	 ƒ  Wd  QXd  S(   Ns   /var/pid(
   R   R   R   Rá   Rt   R:   RÙ   RU   RÏ   RO   (   R#   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_remove_if_stale_broken_pid8  s    
c         C@  sT   t  d ƒ } t ƒ  | _ d  | j _ t ƒ  | _ |  j | j ƒ  ƒ | j j ƒ  d  S(   Ns   /var/pid(	   R   R   Rá   RJ   R6   RÙ   RU   RÏ   RO   (   R#   RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_remove_if_stale_no_pidfileB  s    s   os.fsyncs	   os.getpids   os.opens	   os.fdopenc   	      C@  sû   d | _  d | _  t ƒ  } | _  t ƒ  | _ t ƒ  } | _  | j d ƒ | j d ƒ t d ƒ } | j ƒ  | j d ƒ |  j | j	 ƒ  d ƒ |  j
 | j j ƒ | j ƒ  | j | j t j t j ƒ | j d d ƒ | j d ƒ | j | j ƒ d  S(   Ni  i   s   1816
i    s   /var/pidt   w(   R6   R   R   R/   Rß   Rà   R   RØ   R"   t   readlineRU   R7   RO   Rì   R   t   PIDFILE_FLAGSt   PIDFILE_MODE(	   R#   t   open_t   fdopent   osopent   getpidt   fsyncRù   t   rRÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_write_pidK  s$    		


c   	      C@  sˆ   d | _  d | _  t ƒ  } | _  t ƒ  | _ t ƒ  } | _  | j d ƒ | j d ƒ t d ƒ } |  j t ƒ  | j	 ƒ  Wd  QXd  S(   Ni  i   s   11816
i    s   /var/pid(
   R6   R   R   R/   Rß   Rà   R   RD   R   RØ   (	   R#   Rý   Rþ   Rÿ   R   R  Rù   R  RÓ   (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_write_reread_failse  s    		(   R'   R(   R   R×   RÛ   RÜ   RÞ   Rã   Rå   Rè   Rê   Rë   Rî   Rï   Rñ   Rò   Rô   Rö   R÷   Rø   R   R  R  (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyRÌ   ¨  s6   	
									
	
						!				t   test_setgroupsc           B@  sÚ   e  Z e d  d e ƒd „  ƒ Z e d  d e ƒd „  ƒ Z e d ƒ e d ƒ d „  ƒ ƒ Z e d ƒ e d ƒ d „  ƒ ƒ Z e d ƒ e d ƒ e d ƒ d	 „  ƒ ƒ ƒ Z e d ƒ e d ƒ e d ƒ d
 „  ƒ ƒ ƒ Z	 RS(   s   os.setgroupsR4   c         @  sj   ‡  f d †  } | ˆ  _  t t t d ƒ ƒ ƒ t ƒ  ˆ  _  |  j t ƒ  t t t d ƒ ƒ ƒ Wd  QXd  S(   Nc         @  s,   t  |  ƒ d k r t ˆ  _ d  St ƒ  ‚ d  S(   NiÈ   (   t   lenR5   R6   Rt   (   t   groups(   R   (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   on_setgroups}  s    	i  (   R:   R   t   listt   rangeRt   RD   (   R#   R   R  (    (   R   sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setgroups_hack_ValueErrorz  s    	c      	   @  sÉ   t  ƒ  ‰  t j ˆ  _ ‡  ‡ f d †  } | ˆ _ t t t d ƒ ƒ ƒ ˆ  ˆ _ |  j t  ƒ  t t t d ƒ ƒ ƒ Wd  QXt  ƒ  } t j ˆ  _ | ˆ _ |  j t  ƒ  t t t d ƒ ƒ ƒ Wd  QXd  S(   Nc         @  s)   t  |  ƒ d k r t ˆ _ d  Sˆ  ‚ d  S(   NiÈ   (   R  R5   R6   (   R  (   RB   R   (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR  Ž  s    	i  (	   R9   R;   RŽ   R:   R   R	  R
  RD   Rõ   (   R#   R   R  t   exc2(    (   RB   R   sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setgroups_hack_OSError‰  s    					s
   os.sysconfs    celery.platforms._setgroups_hackc         C@  s<   d | _  t t t d ƒ ƒ ƒ | j t t d ƒ ƒ ƒ d  S(   Nid   i  (   R6   R   R	  R
  RO   (   R#   t   hackt   sysconf(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR  ¡  s    	c         C@  s?   t  ƒ  | _ t t t d ƒ ƒ ƒ | j t t d ƒ ƒ ƒ d  S(   Ni  (   Rt   R:   R   R	  R
  RO   (   R#   R  R  (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setgroups_sysconf_raises¨  s    s   os.getgroupsc         C@  sZ   t  ƒ  | _ t ƒ  } t j | _ | | _ |  j t ƒ  t t t d ƒ ƒ ƒ Wd  QXd  S(   Ni  (	   Rt   R:   R9   R;   Rõ   RD   R   R	  R
  (   R#   R  R  t	   getgroupst   esrch(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setgroups_raises_ESRCH¯  s    		c         C@  s¥   t  ƒ  | _ t ƒ  } t j | _ | | _ t t d ƒ ƒ | _ t t t d ƒ ƒ ƒ | j	 ƒ  d g | _ |  j
 t ƒ  t t t d ƒ ƒ ƒ Wd  QX| j	 ƒ  d  S(   Ni  iè  (   Rt   R:   R9   R;   Rƒ   R	  R
  R6   R   RO   RD   (   R#   R  R  R  t   eperm(    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   test_setgroups_raises_EPERMº  s    		
(
   R'   R(   R   R5   R  R  R  R  R  R  (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyR  x  s   							(;   t
   __future__R    R;   R¨   RZ   RP   R*   t   celeryR   R   t   celery.fiveR   t   celery.platformsR   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   Rx   t   ImportErrorRJ   t   celery.tests.caseR   R   R   R   R   R   R   R   R   R)   R3   RA   RG   RM   t
   IS_WINDOWSRv   R€   R‘   R¢   R­   R»   RÌ   R  (    (    (    sC   /tmp/pip-unpacked-wheel-gV1wwp/celery/tests/utils/test_platforms.pyt   <module>   s:   |
:	
4	A8"&2Ð